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..67993ad4b 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,13 +19,13 @@ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2 with: dotnet-version: '8.0.x' @@ -36,13 +38,13 @@ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2 with: dotnet-version: '8.0.x' @@ -55,10 +57,10 @@ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: dotnet-version: '8.0.x' 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..f3bbb69bb 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/orb-45297c0f1067cd444a30371110c69f876accf55f303a3dce9a4f74863b59f18f.yml +openapi_spec_hash: cd2f638b98c6e89342397fef860166b7 +config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c170..c1ca2977b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,107 @@ # Changelog +## 0.2.0 (2026-05-22) + +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 ([ca37501](https://github.com/orbcorp/orb-csharp/commit/ca375018541ed4cd6f1c01ac834183377a4464ad)) +* **api:** api update ([23fbec1](https://github.com/orbcorp/orb-csharp/commit/23fbec19751d9beaf5934e66f244e28452673fc1)) +* **api:** api update ([c9d1281](https://github.com/orbcorp/orb-csharp/commit/c9d1281358900c18416728626e217e7b6452aa41)) +* **api:** api update ([dd1439d](https://github.com/orbcorp/orb-csharp/commit/dd1439d4595f5fc1baf9b1f2bf65fa98909914b7)) +* **api:** api update ([de37008](https://github.com/orbcorp/orb-csharp/commit/de37008463794bb64f753b8e03050c1c56c8938e)) +* **api:** api update ([64c36c4](https://github.com/orbcorp/orb-csharp/commit/64c36c4de252a6232514eb9640369dcf4596b88e)) +* **api:** api update ([081b59f](https://github.com/orbcorp/orb-csharp/commit/081b59f7971324146548400f0549e31dacf06eab)) +* **api:** api update ([402a658](https://github.com/orbcorp/orb-csharp/commit/402a65877bddeb96bcda28bb70ef0fad26bbd31a)) +* **api:** api update ([fb758b1](https://github.com/orbcorp/orb-csharp/commit/fb758b14367f8eb59cab5b0247b185231d1c4d09)) +* **api:** api update ([a8a9be2](https://github.com/orbcorp/orb-csharp/commit/a8a9be25c0b06fb86e07ad7925dc76bb1160938a)) +* **api:** api update ([7d9a383](https://github.com/orbcorp/orb-csharp/commit/7d9a3839c624f7a6a72d32f5a6a1cf58047cd32d)) +* **api:** api update ([3222676](https://github.com/orbcorp/orb-csharp/commit/3222676a64c7a27dddaa16d17e596825174385f6)) +* **api:** api update ([8c1c3e3](https://github.com/orbcorp/orb-csharp/commit/8c1c3e335c4d40da46c13ad0b5a14166f92be827)) +* **api:** api update ([0d2249f](https://github.com/orbcorp/orb-csharp/commit/0d2249fdcc642b1defe4f284e2c31f968419e8df)) +* **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)) +* support setting headers via env ([0b3d1dd](https://github.com/orbcorp/orb-csharp/commit/0b3d1dd62ee4cc544f390f965eaabec95f0cffa8)) + + +### 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)) +* **internal:** disable default HttpClient timeout as we have our own ([606402c](https://github.com/orbcorp/orb-csharp/commit/606402c733be4a36c58d770b69b0ef2b2110f232)) +* **tests:** round-trip urls correctly ([082b4b4](https://github.com/orbcorp/orb-csharp/commit/082b4b4d09b442c53767c0a7af2f0166e3140021)) + + +### 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:** bump steady to v0.22.1 ([12b342c](https://github.com/orbcorp/orb-csharp/commit/12b342c3911f47b251a0ebaea26b7ef93e6ca0db)) +* **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 + +* improve examples ([c2bedff](https://github.com/orbcorp/orb-csharp/commit/c2bedffefb0e4928864730b1bed1a293a2fd491e)) +* 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..04d29019f 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.22.1 -- steady --version - # Wait for server to come online + npm exec --package=@stdy/cli@0.22.1 -- 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.22.1 -- 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..74b0e5630 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.22.1 -- 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..53e8c0956 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() @@ -83,6 +84,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -130,6 +132,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 +200,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -212,6 +221,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -259,6 +269,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 +353,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -357,6 +374,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -404,6 +422,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 +505,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -501,6 +526,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -548,6 +574,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 +649,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -637,6 +670,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -684,6 +718,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 +802,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -782,6 +823,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -829,6 +871,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 +892,152 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..80372e796 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs @@ -78,7 +78,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/customer_id/customer_id"), url); + Assert.True( + TestBase.UrisEqual( + 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); } } diff --git a/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs index 430dc7d5a..bd00dd856 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs @@ -79,11 +79,31 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/alerts/external_customer_id/external_customer_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/alerts/external_customer_id/external_customer_id" + ), + 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..f3659b996 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs @@ -17,14 +17,41 @@ public void FieldRoundtrip_Works() SubscriptionID = "subscription_id", Thresholds = [new(0)], Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = ["string"], MetricID = "metric_id", + PriceFilters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + PricingUnitID = "pricing_unit_id", + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }; string expectedSubscriptionID = "subscription_id"; List expectedThresholds = [new(0)]; ApiEnum expectedType = AlertCreateForSubscriptionParamsType.UsageExceeded; + List expectedGroupingKeys = ["string"]; string expectedMetricID = "metric_id"; + List expectedPriceFilters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ]; + string expectedPricingUnitID = "pricing_unit_id"; + List expectedThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ]; Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); Assert.Equal(expectedThresholds.Count, parameters.Thresholds.Count); @@ -33,7 +60,26 @@ 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.NotNull(parameters.PriceFilters); + Assert.Equal(expectedPriceFilters.Count, parameters.PriceFilters.Count); + for (int i = 0; i < expectedPriceFilters.Count; i++) + { + Assert.Equal(expectedPriceFilters[i], parameters.PriceFilters[i]); + } + Assert.Equal(expectedPricingUnitID, parameters.PricingUnitID); + Assert.NotNull(parameters.ThresholdOverrides); + Assert.Equal(expectedThresholdOverrides.Count, parameters.ThresholdOverrides.Count); + for (int i = 0; i < expectedThresholdOverrides.Count; i++) + { + Assert.Equal(expectedThresholdOverrides[i], parameters.ThresholdOverrides[i]); + } } [Fact] @@ -46,8 +92,16 @@ 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.PriceFilters); + Assert.False(parameters.RawBodyData.ContainsKey("price_filters")); + Assert.Null(parameters.PricingUnitID); + Assert.False(parameters.RawBodyData.ContainsKey("pricing_unit_id")); + Assert.Null(parameters.ThresholdOverrides); + Assert.False(parameters.RawBodyData.ContainsKey("threshold_overrides")); } [Fact] @@ -59,11 +113,23 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Thresholds = [new(0)], Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = null, MetricID = null, + PriceFilters = null, + PricingUnitID = null, + ThresholdOverrides = 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.PriceFilters); + Assert.True(parameters.RawBodyData.ContainsKey("price_filters")); + Assert.Null(parameters.PricingUnitID); + Assert.True(parameters.RawBodyData.ContainsKey("pricing_unit_id")); + Assert.Null(parameters.ThresholdOverrides); + Assert.True(parameters.RawBodyData.ContainsKey("threshold_overrides")); } [Fact] @@ -78,11 +144,41 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/alerts/subscription_id/subscription_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/alerts/subscription_id/subscription_id"), + url + ) ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertCreateForSubscriptionParams + { + SubscriptionID = "subscription_id", + Thresholds = [new(0)], + Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = ["string"], + MetricID = "metric_id", + PriceFilters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + PricingUnitID = "pricing_unit_id", + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], + }; + + AlertCreateForSubscriptionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AlertCreateForSubscriptionParamsTypeTest : TestBase @@ -138,3 +234,310 @@ public void InvalidEnumSerializationRoundtrip_Works() Assert.Equal(value, deserialized); } } + +public class PriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceFilter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = Field.PriceID; + ApiEnum expectedOperator = Operator.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 PriceFilter + { + Field = Field.PriceID, + Operator = Operator.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 PriceFilter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = Field.PriceID; + ApiEnum expectedOperator = Operator.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 PriceFilter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceFilter + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }; + + PriceFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FieldTest : TestBase +{ + [Theory] + [InlineData(Field.PriceID)] + [InlineData(Field.ItemID)] + [InlineData(Field.PriceType)] + [InlineData(Field.Currency)] + [InlineData(Field.PricingUnitID)] + public void Validation_Works(Field rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Field.PriceID)] + [InlineData(Field.ItemID)] + [InlineData(Field.PriceType)] + [InlineData(Field.Currency)] + [InlineData(Field.PricingUnitID)] + public void SerializationRoundtrip_Works(Field rawValue) + { + // force 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 OperatorTest : TestBase +{ + [Theory] + [InlineData(Operator.Includes)] + [InlineData(Operator.Excludes)] + public void Validation_Works(Operator rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Operator.Includes)] + [InlineData(Operator.Excludes)] + public void SerializationRoundtrip_Works(Operator rawValue) + { + // force 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 ThresholdOverrideTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + List expectedGroupValues = ["string"]; + List expectedThresholds = [new(0)]; + + Assert.Equal(expectedGroupValues.Count, model.GroupValues.Count); + for (int i = 0; i < expectedGroupValues.Count; i++) + { + Assert.Equal(expectedGroupValues[i], model.GroupValues[i]); + } + Assert.Equal(expectedThresholds.Count, model.Thresholds.Count); + for (int i = 0; i < expectedThresholds.Count; i++) + { + Assert.Equal(expectedThresholds[i], model.Thresholds[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdOverride { GroupValues = ["string"], Thresholds = [new(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 ThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedGroupValues = ["string"]; + List expectedThresholds = [new(0)]; + + Assert.Equal(expectedGroupValues.Count, deserialized.GroupValues.Count); + for (int i = 0; i < expectedGroupValues.Count; i++) + { + Assert.Equal(expectedGroupValues[i], deserialized.GroupValues[i]); + } + Assert.Equal(expectedThresholds.Count, deserialized.Thresholds.Count); + for (int i = 0; i < expectedThresholds.Count; i++) + { + Assert.Equal(expectedThresholds[i], deserialized.Thresholds[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + ThresholdOverride copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs index c17bac784..5b2be201e 100644 --- a/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs @@ -55,11 +55,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/alerts/alert_configuration_id/disable?subscription_id=subscription_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/alerts/alert_configuration_id/disable?subscription_id=subscription_id" + ), + 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..e57a08fda 100644 --- a/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs @@ -55,11 +55,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/alerts/alert_configuration_id/enable?subscription_id=subscription_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/alerts/alert_configuration_id/enable?subscription_id=subscription_id" + ), + 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..bde7982eb 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs @@ -35,6 +35,21 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -61,6 +76,18 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -103,6 +130,21 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -143,6 +185,21 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -176,6 +233,18 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -218,6 +287,21 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ], }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -225,4 +309,55 @@ 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"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ], + }, + ], + 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..51e1e4f05 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs @@ -145,6 +145,34 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { AlertListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + Limit = 1, + SubscriptionID = "subscription_id", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/alerts?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&customer_id=customer_id&external_customer_id=external_customer_id&limit=1&subscription_id=subscription_id" + ), + 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"), @@ -157,13 +185,8 @@ public void Url_Works() SubscriptionID = "subscription_id", }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + AlertListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/alerts?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&customer_id=customer_id&external_customer_id=external_customer_id&limit=1&subscription_id=subscription_id" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs index 1f4af2e6e..1c6525443 100644 --- a/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs @@ -22,6 +22,16 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/alert_id"), url); + Assert.True(TestBase.UrisEqual(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..9f34ccd19 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,24 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }; 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 +63,28 @@ 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"); + List expectedPriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + List expectedThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ]; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedCreatedAt, model.CreatedAt); @@ -80,6 +107,25 @@ 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); + Assert.NotNull(model.PriceFilters); + Assert.Equal(expectedPriceFilters.Count, model.PriceFilters.Count); + for (int i = 0; i < expectedPriceFilters.Count; i++) + { + Assert.Equal(expectedPriceFilters[i], model.PriceFilters[i]); + } + Assert.NotNull(model.ThresholdOverrides); + Assert.Equal(expectedThresholdOverrides.Count, model.ThresholdOverrides.Count); + for (int i = 0; i < expectedThresholdOverrides.Count; i++) + { + Assert.Equal(expectedThresholdOverrides[i], model.ThresholdOverrides[i]); + } } [Fact] @@ -104,6 +150,18 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -134,6 +192,18 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -143,7 +213,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 +227,28 @@ 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"); + List expectedPriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + List expectedThresholdOverrides = + [ + new() { GroupValues = ["string"], Thresholds = [new(0)] }, + ]; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); @@ -186,6 +271,25 @@ 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); + Assert.NotNull(deserialized.PriceFilters); + Assert.Equal(expectedPriceFilters.Count, deserialized.PriceFilters.Count); + for (int i = 0; i < expectedPriceFilters.Count; i++) + { + Assert.Equal(expectedPriceFilters[i], deserialized.PriceFilters[i]); + } + Assert.NotNull(deserialized.ThresholdOverrides); + Assert.Equal(expectedThresholdOverrides.Count, deserialized.ThresholdOverrides.Count); + for (int i = 0; i < expectedThresholdOverrides.Count; i++) + { + Assert.Equal(expectedThresholdOverrides[i], deserialized.ThresholdOverrides[i]); + } } [Fact] @@ -210,6 +314,18 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], }; model.Validate(); @@ -240,6 +356,14 @@ 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")); + Assert.Null(model.PriceFilters); + Assert.False(model.RawData.ContainsKey("price_filters")); + Assert.Null(model.ThresholdOverrides); + Assert.False(model.RawData.ContainsKey("threshold_overrides")); } [Fact] @@ -291,10 +415,22 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + GroupingKeys = null, + LicenseType = null, + PriceFilters = null, + ThresholdOverrides = 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")); + Assert.Null(model.PriceFilters); + Assert.True(model.RawData.ContainsKey("price_filters")); + Assert.Null(model.ThresholdOverrides); + Assert.True(model.RawData.ContainsKey("threshold_overrides")); } [Fact] @@ -320,10 +456,55 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + GroupingKeys = null, + LicenseType = null, + PriceFilters = null, + ThresholdOverrides = 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"), + PriceFilters = + [ + new() + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ThresholdOverrides = [new() { GroupValues = ["string"], Thresholds = [new(0)] }], + }; + + Alert copied = new(model); + + Assert.Equal(model, copied); + } } public class MetricTest : TestBase @@ -370,6 +551,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 +643,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 +669,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 +695,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 +781,385 @@ 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); + } +} + +public class AlertPriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AlertPriceFilter + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = AlertPriceFilterField.PriceID; + ApiEnum expectedOperator = + AlertPriceFilterOperator.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 AlertPriceFilter + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.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 AlertPriceFilter + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = AlertPriceFilterField.PriceID; + ApiEnum expectedOperator = + AlertPriceFilterOperator.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 AlertPriceFilter + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AlertPriceFilter + { + Field = AlertPriceFilterField.PriceID, + Operator = AlertPriceFilterOperator.Includes, + Values = ["string"], + }; + + AlertPriceFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AlertPriceFilterFieldTest : TestBase +{ + [Theory] + [InlineData(AlertPriceFilterField.PriceID)] + [InlineData(AlertPriceFilterField.ItemID)] + [InlineData(AlertPriceFilterField.PriceType)] + [InlineData(AlertPriceFilterField.Currency)] + [InlineData(AlertPriceFilterField.PricingUnitID)] + public void Validation_Works(AlertPriceFilterField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AlertPriceFilterField.PriceID)] + [InlineData(AlertPriceFilterField.ItemID)] + [InlineData(AlertPriceFilterField.PriceType)] + [InlineData(AlertPriceFilterField.Currency)] + [InlineData(AlertPriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(AlertPriceFilterField rawValue) + { + // force 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 AlertPriceFilterOperatorTest : TestBase +{ + [Theory] + [InlineData(AlertPriceFilterOperator.Includes)] + [InlineData(AlertPriceFilterOperator.Excludes)] + public void Validation_Works(AlertPriceFilterOperator rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(AlertPriceFilterOperator.Includes)] + [InlineData(AlertPriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(AlertPriceFilterOperator rawValue) + { + // force 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 AlertThresholdOverrideTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new AlertThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + List expectedGroupValues = ["string"]; + List expectedThresholds = [new(0)]; + + Assert.Equal(expectedGroupValues.Count, model.GroupValues.Count); + for (int i = 0; i < expectedGroupValues.Count; i++) + { + Assert.Equal(expectedGroupValues[i], model.GroupValues[i]); + } + Assert.Equal(expectedThresholds.Count, model.Thresholds.Count); + for (int i = 0; i < expectedThresholds.Count; i++) + { + Assert.Equal(expectedThresholds[i], model.Thresholds[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new AlertThresholdOverride { GroupValues = ["string"], Thresholds = [new(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 AlertThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedGroupValues = ["string"]; + List expectedThresholds = [new(0)]; + + Assert.Equal(expectedGroupValues.Count, deserialized.GroupValues.Count); + for (int i = 0; i < expectedGroupValues.Count; i++) + { + Assert.Equal(expectedGroupValues[i], deserialized.GroupValues[i]); + } + Assert.Equal(expectedThresholds.Count, deserialized.Thresholds.Count); + for (int i = 0; i < expectedThresholds.Count; i++) + { + Assert.Equal(expectedThresholds[i], deserialized.Thresholds[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new AlertThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AlertThresholdOverride { GroupValues = ["string"], Thresholds = [new(0)] }; + + AlertThresholdOverride 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..fdc5af03a 100644 --- a/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs @@ -37,6 +37,25 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/alert_configuration_id"), url); + Assert.True( + TestBase.UrisEqual( + 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..fdb128b2d 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -70,8 +70,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -109,6 +160,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 +223,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -210,6 +313,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 +376,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -311,6 +466,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 +534,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -417,6 +624,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -526,184 +734,351 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/versions"), url); + Assert.True( + TestBase.UrisEqual(new Uri("https://api.withorb.com/v1/plans/plan_id/versions"), url) + ); } -} -public class AddAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + 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, - }; - - Adjustment expectedAdjustment = new Models::NewPercentageDiscount() + var parameters = new BetaCreatePlanVersionParams { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + PlanID = "plan_id", + Version = 0, + AddAdjustments = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_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() + AddPrices = + [ + new() + { + AllocationPrice = new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - 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 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() + LicenseAllocationPrice = new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - PlanPhaseOrder = 0, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Adjustment 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 = + 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() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - } - - [Fact] - public void Validation_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() + ReplacePrices = + [ + new() + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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 +{ + [Fact] + public void FieldRoundtrip_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, @@ -712,11 +1087,34 @@ public void Validation_Works() PlanPhaseOrder = 0, }; - model.Validate(); + Adjustment 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, + }; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void SerializationRoundtrip_Works() { var model = new AddAdjustment { @@ -740,14 +1138,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() IsInvoiceLevel = true, PriceType = Models::NewPercentageDiscountPriceType.Usage, }, + PlanPhaseOrder = 0, }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = new AddAdjustment { @@ -771,13 +1175,44 @@ public void OptionalNullablePropertiesUnsetValidation_Works() IsInvoiceLevel = true, PriceType = Models::NewPercentageDiscountPriceType.Usage, }, + PlanPhaseOrder = 0, }; - model.Validate(); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Adjustment 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, + }; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void Validation_Works() { var model = new AddAdjustment { @@ -801,16 +1236,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() IsInvoiceLevel = true, PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - - PlanPhaseOrder = null, + PlanPhaseOrder = 0, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new AddAdjustment { @@ -834,52 +1267,179 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() IsInvoiceLevel = true, PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - - PlanPhaseOrder = null, }; - model.Validate(); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } -} -public class AdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Adjustment value = new Models::NewPercentageDiscount() + var model = new AddAdjustment { - 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, + 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, + }, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewUsageDiscountValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Adjustment value = new Models::NewUsageDiscount() + var model = new AddAdjustment { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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 = null, + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + }; + + 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 +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + Adjustment 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() + { + Adjustment 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 = [ @@ -1165,8 +1725,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1204,6 +1815,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 +1842,58 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1268,11 +1930,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,14 +1967,24 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", @@ -1342,31 +2016,73 @@ 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); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new AddPrice - { - AllocationPrice = new() + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = 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::CustomExpirationDurationUnit.Day, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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 = @@ -1379,8 +2095,59 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1418,6 +2185,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 +2219,58 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; long expectedPlanPhaseOrder = 0; Price expectedPrice = new Models::NewPlanUnitPrice() { @@ -1489,11 +2307,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 +2344,59 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -1563,6 +2434,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 +2450,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 +2472,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,126 +2493,163 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; model.Validate(); } -} - -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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } [Fact] - public void NewPlanTieredValidationWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanTieredPrice() + var model = new AddPrice { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + AllocationPrice = new() { - Tiers = + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, ], - Prorated = true, + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + LicenseAllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + AddPrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class LicenseAllocationPriceTest : TestBase +{ [Fact] - public void NewPlanBulkValidationWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanBulkPrice() + var model = new LicenseAllocationPrice { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1764,29 +2678,114 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(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 BulkWithFiltersValidationWorks() + public void SerializationRoundtrip_Works() { - Price value = new BulkWithFilters() + var model = new LicenseAllocationPrice { - BulkWithFiltersConfig = new() - { - 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, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1815,22 +2814,39 @@ public void BulkWithFiltersValidationWorks() 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 NewPlanPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanPackagePrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1859,79 +2875,124 @@ public void NewPlanPackageValidationWorks() 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() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() { - 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, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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(expectedItemID, deserialized.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(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 NewPlanThresholdTotalAmountValidationWorks() + public void Validation_Works() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1960,257 +3021,213 @@ public void NewPlanThresholdTotalAmountValidationWorks() 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 NewPlanTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanTieredPackagePrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; - 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 NewPlanTieredWithMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanGroupedTieredValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new Models::NewPlanGroupedTieredPrice() + var model = new LicenseAllocationPrice { - 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" }, - ], - }, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - 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 NewPlanTieredPackageWithMinimumValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2239,259 +3256,369 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + + LicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CadenceTest : TestBase +{ + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void InvalidEnumValidationThrows_Works() { - 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, - }, - 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(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 NewPlanMatrixWithAllocationValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class LicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseAllocation { - 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"), - }, + 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 TieredWithProrationValidationWorks() + public void SerializationRoundtrip_Works() { - Price value = new TieredWithProration() + var model = new LicenseAllocation { - Cadence = TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + 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 NewPlanUnitWithProrationValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanUnitWithProrationPrice() + var model = new LicenseAllocation { - 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"), - }, + 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 NewPlanGroupedAllocationValidationWorks() + public void Validation_Works() { - Price value = new Models::NewPlanGroupedAllocationPrice() + var model = new LicenseAllocation { - 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"), - }, + 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 NewPlanBulkWithProrationValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanBulkWithProrationPrice() + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new LicenseAllocation { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + LicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ModelTypeTest : TestBase +{ + [Theory] + [InlineData(ModelType.Unit)] + public void Validation_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ModelType.Unit)] + public void SerializationRoundtrip_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ] ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PriceTest : TestBase +{ + [Fact] + public void NewPlanUnitValidationWorks() + { + Price value = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2520,6 +3647,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2527,21 +3655,27 @@ public void NewPlanBulkWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void NewPlanTieredValidationWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + Price value = new Models::NewPlanTieredPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -2570,6 +3704,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2577,29 +3712,14 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void NewPlanBulkValidationWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + Price value = new Models::NewPlanBulkPrice() { - 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" }, - ], - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2629,6 +3749,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2636,18 +3757,20 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void BulkWithFiltersValidationWorks() { - Price value = new GroupedWithMinMaxThresholds() + Price value = new BulkWithFilters() { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -2678,6 +3801,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2685,27 +3809,15 @@ public void GroupedWithMinMaxThresholdsValidationWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void NewPlanPackageValidationWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + Price value = new Models::NewPlanPackagePrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Models::NewPlanPackagePriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2734,6 +3846,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2741,23 +3854,19 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void NewPlanMatrixValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + Price value = new Models::NewPlanMatrixPrice() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2787,6 +3896,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2794,24 +3904,23 @@ public void NewPlanGroupedTieredPackageValidationWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void NewPlanThresholdTotalAmountValidationWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + Price value = new Models::NewPlanThresholdTotalAmountPrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + ConsumptionTable = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], + Prorate = true, }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2840,6 +3949,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2847,30 +3957,22 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void NewPlanTieredPackageValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + Price value = new Models::NewPlanTieredPackagePrice() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + TieredPackageConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + PackageSize = "package_size", + Tiers = [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2900,6 +4002,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2907,33 +4010,33 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void NewPlanTieredWithMinimumValidationWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + Price value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredWithMinimumConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + HideZeroAmountTiers = true, + Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2963,6 +4066,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2970,26 +4074,22 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanGroupedTieredValidationWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + Price value = new Models::NewPlanGroupedTieredPrice() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - DimensionValues = + GroupingKey = "x", + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Group = "group", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3019,6 +4119,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3026,20 +4127,34 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -3068,6 +4183,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3075,14 +4191,20 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewPlanPackageWithAllocationValidationWorks() { - Price value = new Minimum() + Price value = new Models::NewPlanPackageWithAllocationPrice() { - Cadence = MinimumCadence.Annual, + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + 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() @@ -3111,6 +4233,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3118,15 +4241,15 @@ public void MinimumValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void NewPlanUnitWithPercentValidationWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + Price value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3155,6 +4278,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3162,14 +4286,21 @@ public void NewPlanMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void NewPlanMatrixWithAllocationValidationWorks() { - Price value = new Percent() + Price value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3198,6 +4329,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3205,18 +4337,38 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void MatrixWithThresholdDiscountsValidationWorks() { - Price value = new EventOutput() + Price value = new MatrixWithThresholdDiscounts() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3246,6 +4398,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3253,15 +4406,16 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { - Price value = new Models::NewPlanUnitPrice() + Price value = new TieredWithProration() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3290,37 +4444,23 @@ 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); + value.Validate(); } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void NewPlanUnitWithProrationValidationWorks() { - Price value = new Models::NewPlanTieredPrice() + Price value = new Models::NewPlanUnitWithProrationPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3349,24 +4489,27 @@ 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(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void NewPlanGroupedAllocationValidationWorks() { - Price value = new Models::NewPlanBulkPrice() + Price value = new Models::NewPlanGroupedAllocationPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3396,31 +4539,27 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewPlanBulkWithProrationValidationWorks() { - Price value = new BulkWithFilters() + Price value = new Models::NewPlanBulkWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + BulkWithProrationConfig = new( [ new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3450,25 +4589,29 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - Price value = new Models::NewPlanPackagePrice() + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3497,29 +4640,37 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void NewPlanGroupedWithMeteredMinimumValidationWorks() { - Price value = new Models::NewPlanMatrixPrice() + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + 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" }, + ], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3549,33 +4700,28 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + Price value = new GroupedWithMinMaxThresholds() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, + 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() @@ -3604,33 +4750,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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + MatrixWithDisplayNameConfig = new() { - PackageSize = "package_size", - Tiers = + Dimension = "dimension", + UnitAmounts = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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() @@ -3659,44 +4807,32 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void NewPlanGroupedTieredPackageValidationWorks() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + Price value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { + GroupingKey = "x", + 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", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - HideZeroAmountTiers = true, - Prorate = true, }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3725,32 +4861,31 @@ 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); + value.Validate(); } [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + 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" }, ], }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3780,43 +4915,39 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + ScalableMatrixWithUnitPricingConfig = new() { - PackageSize = 0, - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + 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, @@ -3846,29 +4977,41 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - PackageWithAllocationConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + 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, @@ -3898,25 +5041,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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - Price value = new Models::NewPlanUnitWithPercentPrice() + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3945,30 +5098,27 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + Price value = new CumulativeGroupedAllocation() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3998,26 +5148,29 @@ 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); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void DailyCreditAllowanceValidationWorks() { - Price value = new TieredWithProration() + Price value = new DailyCreditAllowance() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4046,25 +5199,30 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void MeteredAllowanceValidationWorks() { - Price value = new Models::NewPlanUnitWithProrationPrice() + Price value = new MeteredAllowance() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4093,29 +5251,22 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void NewPlanMinimumCompositeValidationWorks() { - Price value = new Models::NewPlanGroupedAllocationPrice() + Price value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4145,30 +5296,22 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void PercentValidationWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + Price value = new Percent() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4197,30 +5340,26 @@ 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); + value.Validate(); } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + Price value = new EventOutput() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4250,40 +5389,23 @@ 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); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + Price value = new Models::NewPlanUnitPrice() { - 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 = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4312,6 +5434,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4322,20 +5445,27 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void NewPlanTieredSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + Price value = new Models::NewPlanTieredPrice() { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -4364,6 +5494,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4374,26 +5505,14 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewPlanBulkSerializationRoundtripWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + Price value = new Models::NewPlanBulkPrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4423,6 +5542,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4433,23 +5553,21 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + Price value = new BulkWithFilters() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4479,6 +5597,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4489,23 +5608,67 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewPlanPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + Price value = new Models::NewPlanPackagePrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanPackagePriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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, @@ -4535,6 +5698,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4545,30 +5709,22 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + Price value = new Models::NewPlanThresholdTotalAmountPrice() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + ThresholdTotalAmountConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + ConsumptionTable = [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - UnitPrice = "unit_price", Prorate = true, - SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4598,6 +5754,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4608,33 +5765,22 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewPlanTieredPackageSerializationRoundtripWorks() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + Price value = new Models::NewPlanTieredPackagePrice() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredPackageConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], + PackageSize = "package_size", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4664,6 +5810,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4674,27 +5821,34 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + Price value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() { - DimensionValues = + Tiers = [ new() { - GroupingKey = "x", + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }, ], - Group = "group", + HideZeroAmountTiers = true, + Prorate = true, }, - ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4723,6 +5877,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4733,19 +5888,22 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void NewPlanGroupedTieredSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new Models::NewPlanGroupedTieredPrice() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Models::NewPlanGroupedTieredPriceCadence.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", + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4775,6 +5933,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4785,14 +5944,34 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - Price value = new Minimum() + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Cadence = MinimumCadence.Annual, + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + 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() @@ -4821,6 +6000,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4831,15 +6011,20 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void NewPlanPackageWithAllocationSerializationRoundtripWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + Price value = new Models::NewPlanPackageWithAllocationPrice() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + 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() @@ -4868,6 +6053,7 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4878,14 +6064,15 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewPlanUnitWithPercentSerializationRoundtripWorks() { - Price value = new Percent() + Price value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = PercentCadence.Annual, + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - PercentConfig = new(0), + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4914,6 +6101,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4924,18 +6112,20 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() { - Price value = new EventOutput() + Price value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ItemID = "item_id", + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4965,6 +6155,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4973,26 +6164,40 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class BulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new MatrixWithThresholdDiscounts() { - BulkWithFiltersConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], }, - Cadence = Cadence.Annual, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5022,99 +6227,75 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - 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"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredWithProrationSerializationRoundtripWorks() + { + Price value = new TieredWithProration() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_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.NotNull(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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewPlanUnitWithProrationSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanUnitWithProrationPrice() { - BulkWithFiltersConfig = new() - { - 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, + 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() @@ -5143,35 +6324,30 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanGroupedAllocationSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanGroupedAllocationPrice() { - BulkWithFiltersConfig = new() + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, - Cadence = Cadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5201,108 +6377,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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - 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"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - 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 NewPlanBulkWithProrationSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanBulkWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + BulkWithProrationConfig = new( [ new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + ] + ), + Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5332,592 +6430,676 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - Cadence = Cadence.Annual, 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.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], }, - Cadence = Cadence.Annual, 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); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new GroupedWithMinMaxThresholds() { - BulkWithFiltersConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_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.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { - var model = new BulkWithFilters + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { - BulkWithFiltersConfig = new() + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Dimension = "dimension", + UnitAmounts = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], }, - Cadence = Cadence.Annual, - ItemID = "item_id", + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_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 BulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() { - var model = new BulkWithFiltersConfig + Price value = new Models::NewPlanGroupedTieredPackagePrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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]); - } + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = new BulkWithFiltersConfig + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = new BulkWithFiltersConfig + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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]); - } - } + Assert.Equal(value, deserialized); + } [Fact] - public void Validation_Works() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var model = new BulkWithFiltersConfig + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class FilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + 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(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + Price value = new CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - 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"; + Price value = new DailyCreditAllowance() + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void MeteredAllowanceSerializationRoundtripWorks() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - model.Validate(); - } -} - -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(); - } -} - -public class CadenceTest : TestBase -{ - [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void Validation_Works(Cadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Cadence.Annual)] - [InlineData(Cadence.SemiAnnual)] - [InlineData(Cadence.Monthly)] - [InlineData(Cadence.Quarterly)] - [InlineData(Cadence.OneTime)] - [InlineData(Cadence.Custom)] - public void SerializationRoundtrip_Works(Cadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class ConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class TieredWithProrationTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new TieredWithProration + Price value = new MeteredAllowance() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5946,18 +7128,229 @@ 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; + 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 Percent() + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 EventOutput() + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); 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() @@ -5966,7 +7359,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5987,14 +7380,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); @@ -6006,6 +7400,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +7415,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.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() @@ -6056,12 +7457,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 ); @@ -6072,14 +7474,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.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() @@ -6108,25 +7516,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 = - TieredWithProrationCadence.Annual; + 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"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); 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() @@ -6135,7 +7549,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6156,14 +7570,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); @@ -6178,6 +7593,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +7608,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.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() @@ -6228,6 +7650,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 +7661,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -6270,6 +7699,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +7710,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -6295,14 +7732,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6315,6 +7758,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6341,6 +7785,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +7796,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new BulkWithFilters { - Cadence = TieredWithProrationCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6370,95 +7822,97 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -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) + 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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>( - json, - ModelBase.SerializerOptions - ); + BulkWithFilters copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class TieredWithProrationConfigTest : TestBase +public class BulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new BulkWithFiltersConfig { - 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() { PropertyKey = "x", PropertyValue = "x" }]; + List expectedTiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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++) { @@ -6469,13 +7923,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new BulkWithFiltersConfig { - 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( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6486,23 +7945,35 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new BulkWithFiltersConfig { - 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; + List expectedTiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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++) { @@ -6513,47 +7984,119 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new BulkWithFiltersConfig { - 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 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 TieredWithProrationConfigTierTest : TestBase +public class FilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + 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 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 TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + 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); } @@ -6561,45 +8104,154 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + 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); - 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 TieredWithProrationConfigTier + 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 { - TierLowerBound = "tier_lower_bound", 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 TieredWithProrationConversionRateConfigTest : TestBase +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 BulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -6610,34 +8262,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, - }, - ] - ), - }; + 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() { - TieredWithProrationConversionRateConfig 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 ); @@ -6648,23 +8299,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, - }, - ] - ), - }; + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6673,22 +8323,41 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class MatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6718,22 +8387,42 @@ 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() + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6744,7 +8433,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6765,15 +8454,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(expectedItemID, model.ItemID); Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig ); - Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -6787,6 +8477,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +8492,36 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6841,12 +8551,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 ); @@ -6857,17 +8568,36 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6897,29 +8627,49 @@ 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() + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6930,7 +8680,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6951,15 +8701,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(expectedItemID, deserialized.ItemID); Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig ); - Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -6976,6 +8727,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +8742,36 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7030,6 +8801,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 +8812,36 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -7076,6 +8867,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +8878,36 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -7105,17 +8917,36 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -7129,6 +8960,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7155,6 +8987,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +8998,36 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", BillableMetricID = null, @@ -7188,57 +9041,129 @@ 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 MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class MatrixWithThresholdDiscountsCadenceTest : 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(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(MatrixWithThresholdDiscountsCadence 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(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsCadence 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); @@ -7247,56 +9172,122 @@ 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 MatrixWithThresholdDiscountsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7307,304 +9298,418 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; 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 expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; model.Validate(); } -} -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void TieredValidationWorks() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - 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 - ); + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void TieredSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - 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 - ); + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); } -} -public class CumulativeGroupedAllocationTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new MatrixWithThresholdDiscountsConfig { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - 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() + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - 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.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + MatrixWithThresholdDiscountsConfig copied = new(model); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new MatrixValue { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7615,503 +9720,305 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new MatrixValue { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; 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() + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixValue { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixValue { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - 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.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixValue { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new MatrixValue { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocation + var model = new MatrixValue { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + MatrixValue copied = new(model); + + Assert.Equal(model, copied); } +} +public class ThresholdDiscountGroupTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new ThresholdDiscountGroup { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - model.Validate(); + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new ThresholdDiscountGroup { - Cadence = CumulativeGroupedAllocationCadence.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, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new ThresholdDiscountGroup { - Cadence = CumulativeGroupedAllocationCadence.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, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - model.Validate(); - } -} + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); -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(); + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + model.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) + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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); + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; - Assert.Equal(value, deserialized); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_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); + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; - Assert.Equal(value, deserialized); + model.Validate(); } -} -public class CumulativeGroupedAllocationConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new ThresholdDiscountGroup { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + Description = null, + }; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new ThresholdDiscountGroup { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + Description = null, + }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new ThresholdDiscountGroup { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + ThresholdDiscountGroup copied = new(model); - 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(); + Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + MatrixWithThresholdDiscountsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8123,7 +10030,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + MatrixWithThresholdDiscountsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -8144,7 +10051,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + MatrixWithThresholdDiscountsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8152,7 +10059,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8163,7 +10070,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + MatrixWithThresholdDiscountsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -8180,7 +10087,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8189,17 +10096,19 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class TieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8228,19 +10137,19 @@ 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 = + TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -8249,7 +10158,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + TieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8270,14 +10179,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(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8289,6 +10199,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8303,12 +10214,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8337,12 +10250,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); } @@ -8350,12 +10267,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8384,26 +10303,26 @@ 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 = + TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -8412,7 +10331,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + TieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8433,14 +10352,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(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8455,6 +10375,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8469,12 +10390,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8503,6 +10426,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8513,12 +10437,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -8543,6 +10469,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8552,12 +10480,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -8566,12 +10496,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -8584,6 +10516,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8610,6 +10543,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8619,12 +10554,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new TieredWithProration { - Cadence = MinimumCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -8637,34 +10574,84 @@ 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumCadenceTest : TestBase +public class TieredWithProrationCadenceTest : 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(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; + 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 +10661,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(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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8697,12 +10684,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 +10698,38 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class TieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8742,120 +10740,185 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + TieredWithProrationConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class TieredWithProrationConfigTierTest : TestBase +{ [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void FieldRoundtrip_Works() { - var model = new MinimumConfig + var model = new TieredWithProrationConfigTier { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new MinimumConfig + var model = new TieredWithProrationConfigTier { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } -} -public class MinimumConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + var model = new TieredWithProrationConfigTier { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - value.Validate(); - } - [Fact] - public void TieredValidationWorks() + 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() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new TieredWithProrationConfigTier { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredWithProrationConversionRateConfig 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,22 +10929,23 @@ 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, - }, - ] - ), - }; + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8890,17 +10954,23 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8929,15 +10999,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 = PercentCadence.Annual; + 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("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8946,7 +11026,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8967,14 +11047,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( + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8986,6 +11070,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11085,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9034,12 +11125,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); } @@ -9047,12 +11142,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9081,22 +11182,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 = PercentCadence.Annual; + 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("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9105,7 +11216,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9126,14 +11237,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( + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9148,6 +11263,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11278,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9196,6 +11318,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 +11329,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -9236,6 +11365,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11376,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -9259,12 +11396,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9277,6 +11420,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9303,6 +11447,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11458,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new GroupedWithMinMaxThresholds { - Cadence = PercentCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9330,34 +11482,88 @@ 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class PercentCadenceTest : TestBase +public class GroupedWithMinMaxThresholdsCadenceTest : 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(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; + 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,22 +11573,21 @@ 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(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; + 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); } @@ -9390,165 +11595,6360 @@ 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< + 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(value, deserialized); + 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 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string json = 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "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"; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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 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 DailyCreditAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); + 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); + 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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", + }; + + DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceCadenceTest : TestBase +{ + [Theory] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(DailyCreditAllowanceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCadence rawValue) + { + // force 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 DailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + List expectedDimensionValues = ["string"]; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = ["string"]; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class MeteredAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string 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(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + } + + [Fact] + public void Validation_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MeteredAllowanceCadenceTest : TestBase +{ + [Theory] + [InlineData(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void Validation_Works(MeteredAllowanceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(MeteredAllowanceCadence rawValue) + { + // force 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 MeteredAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "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 MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); + } + + [Fact] + public void Validation_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; + + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MeteredAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "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", + 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"; + 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.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", + 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", + 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"; + 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.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", + 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", + 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", + Name = "Annual fee", + PercentConfig = new(0), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string json = 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "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"; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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 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 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }; + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }; + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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(); } -} -public class PercentConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PercentConfig { Percent = 0 }; - - double expectedPercent = 0; + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - Assert.Equal(expectedPercent, model.Percent); + 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 SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PercentConfig { Percent = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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); - } + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", - [Fact] - public void Validation_Works() - { - var model = new PercentConfig { Percent = 0 }; + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; - model.Validate(); + 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")); } -} -public class PercentConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + var model = new ReplacePrice { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredValidationWorks() + public void CopyConstructor_Works() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplacePrice { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = 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() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, - ] - ), - }; - 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( + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ] - ), + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputTest : TestBase +public class ReplacePriceLicenseAllocationPriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9577,20 +17977,31 @@ 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() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = + ReplacePriceLicenseAllocationPriceModelType.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() @@ -9599,7 +18010,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9620,14 +18031,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(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(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); @@ -9639,6 +18056,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,17 +18071,22 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9692,12 +18115,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 ); @@ -9708,17 +18132,22 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9747,27 +18176,38 @@ 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() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = + ReplacePriceLicenseAllocationPriceModelType.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() @@ -9776,7 +18216,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9797,53 +18237,300 @@ 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - 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.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.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(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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + 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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + 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 ReplacePriceLicenseAllocationPrice { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9872,213 +18559,263 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - model.Validate(); + ReplacePriceLicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceCadence 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 EventOutput + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePriceLicenseAllocationPriceLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + }; - 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.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", - 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, + WriteOffOverage = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } } -public class EventOutputCadenceTest : TestBase +public class ReplacePriceLicenseAllocationPriceModelTypeTest : 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(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceModelType 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(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceModelType 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); } @@ -10086,1151 +18823,2014 @@ public void SerializationRoundtrip_Works(EventOutputCadence 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 EventOutputConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceConversionRateConfigTest : TestBase { [Fact] - public void FieldRoundtrip_Works() + public void UnitValidationWorks() { - 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); + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void TieredValidationWorks() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + 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 TieredSerializationRoundtripWorks() { - 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); + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + Assert.Equal(value, deserialized); + } +} - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); +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 Validation_Works() + public void NewPlanTieredValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanBulkValidationWorks() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void BulkWithFiltersValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + BulkWithFiltersConfig = new() + { + 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", }; - - 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 NewPlanPackageValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class EventOutputConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewPlanMatrixValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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 TieredValidationWorks() + public void NewPlanThresholdTotalAmountValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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 UnitSerializationRoundtripWorks() + public void NewPlanTieredPackageValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewPlanTieredWithMinimumValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = [ new() { - FirstUnit = 0, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", UnitAmount = "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")); + 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 OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanGroupedTieredValidationWorks() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - var model = new RemoveAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanPackageWithAllocationValidationWorks() { - var model = new RemoveAdjustment + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class RemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanUnitWithPercentValidationWorks() { - 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); + 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 SerializationRoundtrip_Works() + public void NewPlanMatrixWithAllocationValidationWorks() { - 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); + 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 FieldRoundtripThroughSerialization_Works() + public void MatrixWithThresholdDiscountsValidationWorks() { - 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); + ReplacePricePrice value = new ReplacePricePriceMatrixWithThresholdDiscounts() + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void Validation_Works() + public void TieredWithProrationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - model.Validate(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewPlanUnitWithProrationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + 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 OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanGroupedAllocationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanBulkWithProrationValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanGroupedWithMeteredMinimumValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], - 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"], + 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", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - 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, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - 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 = + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }, ], - 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"], + 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", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanGroupedTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + 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", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - ReplacesAdjustmentID = "replaces_adjustment_id", + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + DimensionValues = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewMinimumValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void MeteredAllowanceValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; 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() + public void NewPlanMinimumCompositeValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewAmountDiscountSerializationRoundtripWorks() + public void PercentValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new ReplacePricePricePercent() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewMinimumSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewMaximumSerializationRoundtripWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.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 ); Assert.Equal(value, deserialized); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanTieredSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Tiers = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Prorated = true, }, - 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, }, - }; - - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() + 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() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11259,206 +20859,143 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void BulkWithFiltersSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + BulkWithFiltersConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + 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( - 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 NewPlanPackageSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + 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() { - 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", + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - }; - - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + ExternalPriceID = "external_price_id", + 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() + 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::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanMatrixPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11487,159 +21024,166 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Prorate = true, }, - 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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")); - } - - [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, - PlanPhaseOrder = null, - Price = 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.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanTieredPackageSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11668,34 +21212,37 @@ public void NewPlanUnitValidationWorks() 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 NewPlanTieredValidationWorks() + public void NewPlanGroupedTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { + GroupingKey = "x", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Prorated = true, }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11724,22 +21271,48 @@ public void NewPlanTieredValidationWorks() 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 NewPlanBulkValidationWorks() + public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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() @@ -11768,29 +21341,34 @@ public void NewPlanBulkValidationWorks() 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 BulkWithFiltersValidationWorks() + public void NewPlanPackageWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -11819,22 +21397,29 @@ public void BulkWithFiltersValidationWorks() 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 NewPlanPackageValidationWorks() + public void NewPlanUnitWithPercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11863,26 +21448,34 @@ public void NewPlanPackageValidationWorks() 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 NewPlanMatrixValidationWorks() + public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MatrixWithAllocationConfig = new() { + Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11912,30 +21505,53 @@ public void NewPlanMatrixValidationWorks() 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 NewPlanThresholdTotalAmountValidationWorks() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new ReplacePricePriceMatrixWithThresholdDiscounts() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - ConsumptionTable = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - Prorate = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11964,30 +21580,30 @@ public void NewPlanThresholdTotalAmountValidationWorks() 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 NewPlanTieredPackageValidationWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = ReplacePricePriceTieredWithProrationCadence.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" }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12016,41 +21632,29 @@ public void NewPlanTieredPackageValidationWorks() 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 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, - }, + 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() @@ -12079,29 +21683,33 @@ public void NewPlanTieredWithMinimumValidationWorks() 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 NewPlanGroupedTieredValidationWorks() + public void NewPlanGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanGroupedAllocationPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12131,41 +21739,34 @@ public void NewPlanGroupedTieredValidationWorks() 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 NewPlanTieredPackageWithMinimumValidationWorks() + public void NewPlanBulkWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + 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::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.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() @@ -12194,27 +21795,35 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -12243,22 +21852,44 @@ public void NewPlanPackageWithAllocationValidationWorks() 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 NewPlanUnitWithPercentValidationWorks() + public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + 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::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12287,27 +21918,33 @@ public void NewPlanUnitWithPercentValidationWorks() 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 NewPlanMatrixWithAllocationValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.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 = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12337,23 +21974,41 @@ public void NewPlanMatrixWithAllocationValidationWorks() 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 TieredWithProrationValidationWorks() + public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + 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", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12382,22 +22037,38 @@ public void TieredWithProrationValidationWorks() 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 NewPlanUnitWithProrationValidationWorks() + public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + 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::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12426,26 +22097,37 @@ public void NewPlanUnitWithProrationValidationWorks() 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 NewPlanGroupedAllocationValidationWorks() + public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12475,27 +22157,46 @@ public void NewPlanGroupedAllocationValidationWorks() 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 NewPlanBulkWithProrationValidationWorks() + public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -12524,28 +22225,48 @@ public void NewPlanBulkWithProrationValidationWorks() 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 NewPlanGroupedWithProratedMinimumValidationWorks() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -12574,36 +22295,40 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() 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 NewPlanGroupedWithMeteredMinimumValidationWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + DimensionValues = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], + Group = "group", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12633,24 +22358,31 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() 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 GroupedWithMinMaxThresholdsValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -12682,33 +22414,34 @@ public void GroupedWithMinMaxThresholdsValidationWorks() 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 NewPlanMatrixWithDisplayNameValidationWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12738,30 +22471,35 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() 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 NewPlanGroupedTieredPackageValidationWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12791,30 +22529,28 @@ public void NewPlanGroupedTieredPackageValidationWorks() 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 NewPlanMaxGroupTieredPackageValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.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, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12844,38 +22580,28 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() 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 NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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", - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12904,41 +22630,33 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() 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 NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = 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", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12967,33 +22685,38 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() 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); } +} +public class ReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + BulkWithFiltersConfig = new() { - DimensionValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Group = "group", }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13023,25 +22746,101 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + 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 CumulativeGroupedAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -13072,20 +22871,36 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceMinimumCadence.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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13115,21 +22930,112 @@ public void MinimumValidationWorks() 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); + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + 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 NewPlanMinimumCompositeValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanMinimumCompositePriceCadence.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", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13159,175 +23065,203 @@ public void NewPlanMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new ReplacePricePricePercent() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", }; - 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 EventOutputValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + BulkWithFiltersConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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(); + + model.Validate(); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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() + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + 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 NewPlanTieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + BulkWithFiltersConfig = new() { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Prorated = true, }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13356,662 +23290,561 @@ 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( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [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 + { + 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 NewPlanBulkSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - BulkWithFiltersConfig = new() - { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + 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 NewPlanPackageSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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() + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + ReplacePricePriceBulkWithFiltersConversionRateConfig 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsTest : TestBase +{ [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14041,29 +23874,143 @@ 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 + + ApiEnum expectedCadence = + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14092,28 +24039,55 @@ 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 - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14142,32 +24116,153 @@ 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 + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14197,88 +24292,287 @@ 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 - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14308,792 +24602,1049 @@ 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 + + ReplacePricePriceMatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue) + { + // force 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(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() - { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - 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 - ); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() - { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Dimension = "dimension", - UnitAmounts = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - DimensionValue = "dimension_value", - DisplayName = "display_name", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - 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 - ); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() - { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() - { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { + DefaultUnitAmount = "default_unit_amount", FirstDimension = "first_dimension", - MatrixScalingFactors = + MatrixValues = [ new() { FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", + UnitAmount = "unit_amount", 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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 - ); + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], - Assert.Equal(value, deserialized); + SecondDimension = null, + }; + + model.Validate(); } [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() - { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { + DefaultUnitAmount = "default_unit_amount", FirstDimension = "first_dimension", - MatrixScalingFactors = + MatrixValues = [ new() { FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", + UnitAmount = "unit_amount", SecondDimensionValue = "second_dimension_value", }, ], - Tiers = + SecondDimension = "second_dimension", + ThresholdDiscountGroups = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - 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 - ); + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; - Assert.Equal(value, deserialized); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - 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 - ); + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", - Assert.Equal(value, deserialized); + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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 + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } - Assert.Equal(value, deserialized); + [Fact] + public void Validation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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 - ); + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", - Assert.Equal(value, deserialized); + Description = null, + }; + + model.Validate(); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void CopyConstructor_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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); + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() + { + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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 EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceBulkWithFiltersTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15122,24 +25673,18 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -15148,7 +25693,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15169,14 +25714,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); @@ -15188,6 +25734,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -15197,25 +25744,19 @@ public void FieldRoundtrip_Works() 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, + } + + [Fact] + public void SerializationRoundtrip_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() @@ -15244,12 +25785,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 ); @@ -15260,20 +25802,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15302,31 +25838,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); - 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 = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -15335,7 +25865,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15356,14 +25886,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); @@ -15378,6 +25909,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25924,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15434,6 +25960,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 +25971,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -15482,6 +26003,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26014,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -15513,20 +26030,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -15539,6 +26050,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15565,6 +26077,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15572,266 +26086,181 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new ReplacePricePriceTieredWithProration { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new ReplacePricePriceTieredWithProration { - PropertyKey = "x", - PropertyValue = "x", + 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + ReplacePricePriceTieredWithProration copied = new(model); - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +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) { - 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); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + [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) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 ); @@ -15842,158 +26271,150 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - model.Validate(); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) + [Fact] + public void Validation_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); + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16005,7 +26426,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16026,7 +26447,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16034,7 +26455,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16045,7 +26466,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16062,7 +26483,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16071,19 +26492,23 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26537,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 = - ReplacePricePriceTieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26565,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16152,14 +26586,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( + 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); @@ -16171,6 +26609,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26624,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26664,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 +26681,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26721,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26756,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16320,14 +26777,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( + 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); @@ -16342,6 +26803,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26818,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26858,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 +26869,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -16434,6 +26905,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26916,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16459,14 +26936,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16479,6 +26960,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16505,6 +26987,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26998,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16534,27 +27022,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 ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : 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) + [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(); } @@ -16562,7 +27104,7 @@ public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValu public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -16570,20 +27112,22 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + 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); @@ -16593,50 +27137,58 @@ public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCad 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ); @@ -16647,123 +27199,75 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - model.Validate(); - } -} - -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); + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; - model.Validate(); + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new( + model + ); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16775,7 +27279,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16796,7 +27300,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16804,7 +27308,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16815,7 +27319,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16832,7 +27336,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16841,20 +27345,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -16886,23 +27390,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 = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -16913,7 +27418,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16934,13 +27439,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -16956,6 +27462,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,15 +27477,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17010,12 +27517,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,15 +27534,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17066,30 +27574,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 = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17100,7 +27609,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17121,13 +27630,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17146,6 +27656,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,15 +27671,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17200,6 +27711,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17210,15 +27722,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17246,6 +27758,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +27769,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17275,15 +27789,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17299,6 +27813,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17325,6 +27840,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +27851,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17358,27 +27875,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 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 ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : 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(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(); } @@ -17386,7 +27957,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 +27965,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + 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); @@ -17419,58 +27990,58 @@ 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 +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17482,55 +28053,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17542,7 +28132,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17563,7 +28153,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17571,7 +28161,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17582,7 +28172,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17599,7 +28189,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17608,20 +28198,21 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17653,24 +28244,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 = + ReplacePricePriceDailyCreditAllowanceCadence.Annual; + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -17680,7 +28271,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17701,14 +28292,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -17723,6 +28312,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +28327,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17777,12 +28368,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 +28385,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17833,31 +28426,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 = + ReplacePricePriceDailyCreditAllowanceCadence.Annual; + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -17867,7 +28460,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17888,14 +28481,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -17913,6 +28504,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +28519,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17967,6 +28560,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 +28571,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18013,6 +28608,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28619,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18042,15 +28640,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18066,6 +28665,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18092,6 +28692,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,51 +28703,107 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 ReplacePricePriceDailyCreditAllowance + { + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - model.Validate(); + ReplacePricePriceDailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceCadenceTest : 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(ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Custom)] + public void Validation_Works(ReplacePricePriceDailyCreditAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18153,7 +28811,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 +28819,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue - ) + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceDailyCreditAllowanceCadence 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 +28842,189 @@ 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 ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18248,56 +29035,66 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = new( + model + ); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18309,7 +29106,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18330,7 +29127,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18338,7 +29135,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18349,7 +29146,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18366,7 +29163,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18375,16 +29172,24 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18414,19 +29219,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 = + ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18436,7 +29247,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18457,12 +29268,13 @@ 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(expectedMinimumConfig, model.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18476,6 +29288,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +29303,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18524,12 +29345,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 +29362,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18574,26 +29404,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 = + ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18603,7 +29439,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18624,12 +29460,13 @@ 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(expectedMinimumConfig, deserialized.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18646,6 +29483,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +29498,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18694,6 +29540,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 +29551,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -18734,6 +29589,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29600,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -18757,11 +29622,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -18775,6 +29648,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18801,6 +29675,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29686,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -18828,57 +29712,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 ReplacePricePriceMeteredAllowance + { + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceMeteredAllowanceCadenceTest : 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(ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Custom)] + public void Validation_Works(ReplacePricePriceMeteredAllowanceCadence 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(ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceMeteredAllowanceCadence 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 +29826,67 @@ 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 ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18939,33 +29894,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -18974,16 +29946,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -18991,39 +29977,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19035,7 +30049,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19056,17 +30070,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new 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 +30089,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19090,10 +30105,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 +30154,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 +30194,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 +30214,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +30263,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 +30314,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 +30361,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 +30384,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +30433,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 +30474,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30517,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19517,6 +30544,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30573,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 +30743,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 +30880,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 +30925,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 +30945,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +30999,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 +31055,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 +31107,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 +31130,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +31184,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 +31230,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31283,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20212,6 +31310,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31344,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 +31597,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..74d82a79e 100644 --- a/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs @@ -24,6 +24,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/versions/version"), url); + Assert.True( + TestBase.UrisEqual( + 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..f6d1c5544 100644 --- a/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs @@ -24,6 +24,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/set_default_version"), url); + Assert.True( + TestBase.UrisEqual( + 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..045b52ce3 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -70,8 +70,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -109,6 +160,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 +223,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -210,6 +313,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 +376,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -311,6 +466,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 +534,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, PlanPhaseOrder = 0, Price = new Models::NewPlanUnitPrice() { @@ -417,6 +624,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -534,723 +742,7124 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/versions"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/versions" + ), + url + ) ); } -} -public class AddAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + 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, - }; - - Adjustment expectedAdjustment = new Models::NewPercentageDiscount() + var parameters = new ExternalPlanIDCreatePlanVersionParams { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + ExternalPlanID = "external_plan_id", + Version = 0, + AddAdjustments = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new AddAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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 +{ + [Fact] + public void FieldRoundtrip_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, + }; + + Adjustment 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, + }; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + } + + [Fact] + public void SerializationRoundtrip_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, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Adjustment 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, + }; + long expectedPlanPhaseOrder = 0; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + } + + [Fact] + public void Validation_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, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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, + }, + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + }; + + 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 = + 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 +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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() + { + Adjustment 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 AddPriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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", + }, + }; + + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; + long expectedPlanPhaseOrder = 0; + Price 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(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 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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); + + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; + long expectedPlanPhaseOrder = 0; + Price 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(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 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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 AddPrice { }; + + 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 AddPrice { }; + + model.Validate(); + } + + [Fact] + 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); + Assert.True(model.RawData.ContainsKey("price")); + } + + [Fact] + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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 LicenseAllocationPriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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); + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, deserialized.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], deserialized.LicenseAllocations[i]); + } + Assert.Equal(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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, + 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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, + 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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, + 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 LicenseAllocationPrice + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; + + LicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CadenceTest : TestBase +{ + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void SerializationRoundtrip_Works(Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class LicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + LicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ModelTypeTest : TestBase +{ + [Theory] + [InlineData(ModelType.Unit)] + public void Validation_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ModelType.Unit)] + public void SerializationRoundtrip_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = 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 MatrixWithThresholdDiscountsValidationWorks() + { + Price value = new MatrixWithThresholdDiscounts() + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = 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 TieredWithProration() + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 GroupedWithMinMaxThresholds() + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + Price value = new DailyCreditAllowance() + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 MeteredAllowanceValidationWorks() + { + Price value = new MeteredAllowance() + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = 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 Percent() + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + Price value = new EventOutput() + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + Price value = new MatrixWithThresholdDiscounts() + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 TieredWithProration() + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 GroupedWithMinMaxThresholds() + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", }, - PlanPhaseOrder = 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); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", }, - PlanPhaseOrder = 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); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Equal(value, deserialized); + } - Adjustment expectedAdjustment = new Models::NewPercentageDiscount() + [Fact] + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - long expectedPlanPhaseOrder = 0; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new DailyCreditAllowance() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - 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, + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - PlanPhaseOrder = 0, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_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 MeteredAllowanceSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new MeteredAllowance() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_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.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanMinimumCompositePrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - 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, + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_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 PercentSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new Percent() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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, + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - - PlanPhaseOrder = null, + LicenseTypeID = "license_type_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.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void EventOutputSerializationRoundtripWorks() { - var model = new AddAdjustment + Price value = new EventOutput() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - - PlanPhaseOrder = null, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_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 AdjustmentTest : TestBase +public class BulkWithFiltersTest : TestBase { [Fact] - public void NewPercentageDiscountValidationWorks() + public void FieldRoundtrip_Works() { - Adjustment value = new Models::NewPercentageDiscount() + var model = new BulkWithFilters { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + BulkWithFiltersConfig = new() + { + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); - } - [Fact] - public void NewUsageDiscountValidationWorks() - { - Adjustment value = new Models::NewUsageDiscount() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.Usage, }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - Adjustment value = new Models::NewAmountDiscount() + ApiEnum expectedCadence = BulkWithFiltersCadence.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() { - 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, + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; - value.Validate(); - } - - [Fact] - public void NewMinimumValidationWorks() - { - Adjustment value = new Models::NewMinimum() + double expectedConversionRate = 0; + BulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { - 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, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }; - value.Validate(); - } - - [Fact] - public void NewMaximumValidationWorks() - { - Adjustment 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 expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; - value.Validate(); + 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 NewPercentageDiscountSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Adjustment value = new Models::NewPercentageDiscount() + var model = new BulkWithFilters { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + BulkWithFiltersConfig = new() + { + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 NewUsageDiscountSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Adjustment value = new Models::NewUsageDiscount() + var model = new BulkWithFilters { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + BulkWithFiltersConfig = new() + { + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.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 NewAmountDiscountSerializationRoundtripWorks() - { - Adjustment value = new Models::NewAmountDiscount() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.Usage, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + ApiEnum expectedCadence = BulkWithFiltersCadence.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; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Adjustment value = new Models::NewMinimum() + var model = new BulkWithFilters { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + BulkWithFiltersConfig = new() + { + 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", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewMaximumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Adjustment value = new Models::NewMaximum() + var model = new BulkWithFilters { - 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, + BulkWithFiltersConfig = new() + { + 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", + 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")); } -} -public class AddPriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new AddPrice + var model = new BulkWithFilters { - AllocationPrice = new() + BulkWithFiltersConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + Cadence = BulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithFilters + { + BulkWithFiltersConfig = 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", + 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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Models::NewAllocationPrice expectedAllocationPrice = new() + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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 { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + BulkWithFiltersConfig = new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - long expectedPlanPhaseOrder = 0; - Price expectedPrice = new Models::NewPlanUnitPrice() + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFilters { - Cadence = Models::NewPlanUnitPriceCadence.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 = BulkWithFiltersCadence.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() @@ -1279,305 +7888,252 @@ 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(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); } +} +public class BulkWithFiltersConfigTest : TestBase +{ [Fact] - public void SerializationRoundtrip_Works() + public void FieldRoundtrip_Works() { - var model = new AddPrice + var model = new BulkWithFiltersConfig { - 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", - }, + 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); + 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(model, deserialized); + 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 FieldRoundtripThroughSerialization_Works() + public void SerializationRoundtrip_Works() { - var model = new AddPrice + var model = new BulkWithFiltersConfig { - 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", - }, + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Models::NewAllocationPrice expectedAllocationPrice = new() + 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++) { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + 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() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }; - long expectedPlanPhaseOrder = 0; - Price expectedPrice = new Models::NewPlanUnitPrice() + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithFiltersConfig { - 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", + 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(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + 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 AddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() - { - Cadence = Models::NewPlanUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - }; + 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(); } @@ -1585,20 +8141,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new AddPrice { }; + var model = new Tier { UnitAmount = "unit_amount" }; - 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.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new AddPrice { }; + var model = new Tier { UnitAmount = "unit_amount" }; model.Validate(); } @@ -1606,458 +8158,220 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new AddPrice + var model = new Tier { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + UnitAmount = "unit_amount", + + TierLowerBound = 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.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new AddPrice + var model = new Tier { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + UnitAmount = "unit_amount", + + TierLowerBound = null, }; model.Validate(); } -} -public class PriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void CopyConstructor_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; - [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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Tier copied = new(model); + + Assert.Equal(model, copied); } +} - [Fact] - public void NewPlanBulkValidationWorks() +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) { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void BulkWithFiltersValidationWorks() - { - Price value = new BulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 NewPlanPackageValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanPackagePrice() + 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 BulkWithFiltersConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } [Fact] - public void NewPlanMatrixValidationWorks() + public void TieredValidationWorks() { - Price value = new Models::NewPlanMatrixPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackagePrice() + BulkWithFiltersConversionRateConfig 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(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class MatrixWithThresholdDiscountsTest : TestBase +{ [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - HideZeroAmountTiers = true, - Prorate = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2086,29 +8400,141 @@ 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 = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.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() { - Price value = new Models::NewPlanGroupedTieredPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2138,41 +8564,54 @@ 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() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - PackageSize = 0, - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2201,27 +8640,152 @@ 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 = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.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() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2250,161 +8814,288 @@ 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() { - Price value = new Models::NewPlanUnitWithPercentPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Name = "Annual fee", }; - 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() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredWithProrationValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new TieredWithProration() + var model = new MatrixWithThresholdDiscounts { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanUnitWithProrationValidationWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanUnitWithProrationPrice() + var model = new MatrixWithThresholdDiscounts { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2433,1053 +9124,1004 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + + MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void InvalidEnumValidationThrows_Works() { - Price value = new Models::NewPlanGroupedAllocationPrice() + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class MatrixWithThresholdDiscountsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - 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() + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - value.Validate(); + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - Price value = new Models::NewPlanBulkWithProrationPrice() + var model = new MatrixWithThresholdDiscountsConfig { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new MatrixWithThresholdDiscountsConfig { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - value.Validate(); + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new MatrixWithThresholdDiscountsConfig { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - value.Validate(); + + model.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new GroupedWithMinMaxThresholds() + var model = new MatrixWithThresholdDiscountsConfig { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new MatrixWithThresholdDiscountsConfig { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - value.Validate(); + + MatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class MatrixValueTest : TestBase +{ [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - value.Validate(); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new MatrixValue { - 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - value.Validate(); + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new CumulativeGroupedAllocation() + var model = new MatrixValue { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, }; - value.Validate(); + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void MinimumValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Price value = new Minimum() + var model = new MatrixValue { - 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", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdDiscountGroupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new ThresholdDiscountGroup { - 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", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - value.Validate(); + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); } [Fact] - public void PercentValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Percent() + var model = new ThresholdDiscountGroup { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void EventOutputValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new EventOutput() + var model = new ThresholdDiscountGroup { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - value.Validate(); + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Price value = new Models::NewPlanUnitPrice() + var model = new ThresholdDiscountGroup { - 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", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanTieredPrice() + var model = new ThresholdDiscountGroup { - 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() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ThresholdDiscountGroup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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); + }; + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - 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() + MatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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 BulkWithFiltersSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new BulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MatrixWithThresholdDiscountsConversionRateConfig 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(element, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class TieredWithProrationTest : TestBase +{ [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanPackagePrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3508,85 +10150,91 @@ 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); - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() - { - Price value = new Models::NewPlanMatrixPrice() + ApiEnum expectedCadence = + TieredWithProrationCadence.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" }] + ); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - 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() + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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.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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new TieredWithProration { - 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, - }, + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3615,33 +10263,31 @@ 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); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanTieredPackagePrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredWithProrationCadence.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" }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3670,44 +10316,101 @@ 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); - Assert.Equal(value, deserialized); + 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"; + 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.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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanTieredWithMinimumPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredWithProrationCadence.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, - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3736,33 +10439,173 @@ 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + 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", + 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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanGroupedTieredPrice() + var model = new TieredWithProration { - 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" }, - ], - }, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3791,342 +10634,355 @@ 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); + + 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + 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 TieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfig { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredWithProrationConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanUnitWithPercentPrice() + var model = new TieredWithProrationConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredWithProrationConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new TieredWithProration() + var model = new TieredWithProrationConfigTier { - Cadence = TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + 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() { - 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, + }, + ] + ), + }; + 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + TieredWithProrationConversionRateConfig 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(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class GroupedWithMinMaxThresholdsTest : TestBase +{ [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanGroupedAllocationPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Allocation = "allocation", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4156,82 +11012,103 @@ 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); - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() - { - Price value = new Models::NewPlanBulkWithProrationPrice() + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - 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() + 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; + GroupedWithMinMaxThresholdsConversionRateConfig 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( + 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4261,39 +11138,34 @@ 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); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4323,19 +11195,103 @@ 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); - Assert.Equal(value, deserialized); + 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new GroupedWithMinMaxThresholds() + var model = new GroupedWithMinMaxThresholds { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4375,92 +11331,192 @@ 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); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ItemID = "item_id", Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - 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 CopyConstructor_Works() { - Price value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4490,163 +11546,285 @@ 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); + + 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + 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 { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { - 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() + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() - { - 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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", - 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() + GroupedWithMinMaxThresholdsConversionRateConfig 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(element, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class CumulativeGroupedAllocationTest : TestBase +{ [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new CumulativeGroupedAllocation { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = 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", + 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() @@ -4675,36 +11853,103 @@ 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); - Assert.Equal(value, deserialized); + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig 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; + 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.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new CumulativeGroupedAllocation { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4734,19 +11979,24 @@ 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); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new CumulativeGroupedAllocation() + var model = new CumulativeGroupedAllocation { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -4786,23 +12036,113 @@ 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); + 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Minimum() + var model = new CumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = CumulativeGroupedAllocationCadence.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, @@ -4832,71 +12172,193 @@ 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(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new CumulativeGroupedAllocation { - 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() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + 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 CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Percent() + var model = new CumulativeGroupedAllocation { - Cadence = PercentCadence.Annual, + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4925,84 +12387,284 @@ 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); + + 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 EventOutputSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new EventOutput() + 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 { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - 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() + { + CumulativeGroupedAllocationConversionRateConfig 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() + { + CumulativeGroupedAllocationConversionRateConfig 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() + { + CumulativeGroupedAllocationConversionRateConfig 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(element, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class BulkWithFiltersTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5033,22 +12695,23 @@ 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() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5058,7 +12721,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5079,11 +12742,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5098,6 +12762,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,18 +12777,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5154,12 +12818,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 ); @@ -5170,18 +12835,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5212,29 +12876,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5244,7 +12909,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5265,11 +12930,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -5287,6 +12953,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,18 +12968,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5343,6 +13009,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5353,18 +13020,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5391,6 +13057,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,18 +13068,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5422,18 +13089,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5448,6 +13114,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5474,6 +13141,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,18 +13152,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new DailyCreditAllowance { - BulkWithFiltersConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5509,63 +13177,187 @@ 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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", + }; + + DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceCadenceTest : TestBase +{ + [Theory] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(DailyCreditAllowanceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCadence rawValue) + { + // force 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 BulkWithFiltersConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new DailyCreditAllowanceConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ]; - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) { - Assert.Equal(expectedFilters[i], model.Filters[i]); + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) { - Assert.Equal(expectedTiers[i], model.Tiers[i]); + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new DailyCreditAllowanceConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5576,130 +13368,115 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFiltersConfig + var model = new DailyCreditAllowanceConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ]; - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); } } [Fact] public void Validation_Works() { - var model = new BulkWithFiltersConfig + var model = new DailyCreditAllowanceConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; model.Validate(); } -} - -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() + public void CopyConstructor_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); - } + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; - [Fact] - public void Validation_Works() - { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + DailyCreditAllowanceConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class TierTest : TestBase +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } 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" }; + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + 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); } @@ -5707,181 +13484,103 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } 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 + var model = new DailyCreditAllowanceConfigMatrixValue { + DimensionValues = ["string"], 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); + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); } } -public class ConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + DailyCreditAllowanceConversionRateConfig 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 ); @@ -5892,22 +13591,23 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + DailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = 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 ); @@ -5916,19 +13616,25 @@ public void TieredSerializationRoundtripWorks() } } -public class TieredWithProrationTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5957,18 +13663,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 = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); 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() @@ -5977,7 +13689,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5998,14 +13710,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(expectedItemID, model.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); 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); @@ -6017,6 +13730,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +13745,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6067,12 +13787,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 ); @@ -6083,14 +13804,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6119,25 +13846,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 = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); 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() @@ -6146,7 +13879,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6167,14 +13900,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(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); 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); @@ -6189,6 +13923,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +13938,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6239,6 +13980,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 +13991,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -6281,6 +14029,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +14040,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -6306,14 +14062,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6326,6 +14088,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6352,6 +14115,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +14126,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new MeteredAllowance { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6381,56 +14152,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 MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void Validation_Works(MeteredAllowanceCadence 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 ); - 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) + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(MeteredAllowanceCadence 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 +14268,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 +14282,51 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationConfigTest : TestBase +public class MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new MeteredAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "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(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new MeteredAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6497,120 +14337,149 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new MeteredAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "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(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new MeteredAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfigTier + var model = new MeteredAllowanceConfig { - TierLowerBound = "tier_lower_bound", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", UnitAmount = "unit_amount", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new MeteredAllowanceConfig { - TierLowerBound = "tier_lower_bound", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", UnitAmount = "unit_amount", }; - 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 OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new TieredWithProrationConfigTier + var model = new MeteredAllowanceConfig { - TierLowerBound = "tier_lower_bound", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); + } - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new MeteredAllowanceConfig { - TierLowerBound = "tier_lower_bound", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - model.Validate(); + MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -6621,34 +14490,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, - }, - ] - ), - }; + MeteredAllowanceConversionRateConfig 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() + MeteredAllowanceConversionRateConfig 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 +14527,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, - }, - ] - ), - }; + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = 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,23 +14551,17 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6729,24 +14590,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 = - GroupedWithMinMaxThresholdsCadence.Annual; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + 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() @@ -6755,7 +14608,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6776,17 +14629,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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6798,6 +14649,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,18 +14664,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6852,15 +14698,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,18 +14712,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6908,31 +14746,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 = - 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" - ); + ApiEnum expectedCadence = PercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6941,7 +14771,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6962,17 +14792,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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6987,6 +14815,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,18 +14830,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7041,6 +14864,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7051,18 +14875,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -7087,6 +14905,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,18 +14916,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -7116,18 +14930,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7140,6 +14948,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7166,6 +14975,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,18 +14986,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new Percent { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7199,34 +15004,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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class PercentCadenceTest : 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(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 ); @@ -7236,21 +15089,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(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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7258,204 +15112,346 @@ 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 PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + 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() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + value.Validate(); + } - 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 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 SerializationRoundtrip_Works() + public void UnitSerializationRoundtripWorks() { - var model = new GroupedWithMinMaxThresholdsConfig + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - 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 TieredSerializationRoundtripWorks() { - var model = new GroupedWithMinMaxThresholdsConfig + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; - - 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 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(); + Assert.Equal(value, deserialized); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class EventOutputTest : TestBase { [Fact] - public void UnitValidationWorks() + public void FieldRoundtrip_Works() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig 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", + }; - [Fact] - public void UnitSerializationRoundtripWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig value = + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration 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(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 TieredSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + var model = new EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - 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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } -} -public class CumulativeGroupedAllocationTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new EventOutput { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", Name = "Annual fee", @@ -7487,23 +15483,27 @@ 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() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7513,7 +15513,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7534,51 +15534,262 @@ 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.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(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.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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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 { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new CumulativeGroupedAllocation + var model = new EventOutput { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", Name = "Annual fee", @@ -7610,198 +15821,356 @@ public void SerializationRoundtrip_Works() 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( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + 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 FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new EventOutputConfig { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + model.Validate(); + } - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + [Fact] + public void CopyConstructor_Works() + { + var model = new EventOutputConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - 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() + + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class EventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - 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 + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void TieredSerializationRoundtripWorks() { - var model = new CumulativeGroupedAllocation + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "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(); } @@ -7809,64 +16178,16 @@ public void Validation_Works() [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", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation - { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; model.Validate(); } @@ -7874,198 +16195,62 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new RemoveAdjustment { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new RemoveAdjustment { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; model.Validate(); } -} - -public class 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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - [Fact] - public 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); + RemoveAdjustment copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class RemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8076,284 +16261,178 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; model.Validate(); } -} -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + var model = new RemovePrice { PriceID = "price_id" }; + + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void TieredValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_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 RemovePrice { PriceID = "price_id" }; + + model.Validate(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 RemovePrice + { + PriceID = "price_id", - Assert.Equal(value, deserialized); + PlanPhaseOrder = null, + }; + + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void TieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_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 RemovePrice + { + PriceID = "price_id", - Assert.Equal(value, deserialized); + 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 MinimumTest : TestBase +public class ReplaceAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ApiEnum expectedCadence = MinimumCadence.Annual; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; - 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) + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + 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(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; 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,161 +16440,94 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - 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() + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }; - 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 expectedReplacesAdjustmentID = "replaces_adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; model.Validate(); @@ -8524,51 +16536,61 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + 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.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + 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(); @@ -8577,296 +16599,360 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + 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", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new ReplaceAdjustment { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class MinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void Validation_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class MinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + 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.Equal(model, deserialized); + PlanPhaseOrder = null, + }; + + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_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 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + ReplaceAdjustment copied = new(model); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(model, copied); } +} +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void Validation_Works() + public void NewPercentageDiscountValidationWorks() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); + 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 OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void NewUsageDiscountValidationWorks() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + 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 OptionalNonNullablePropertiesUnsetValidation_Works() + public void NewAmountDiscountValidationWorks() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); + 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 OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void NewMinimumValidationWorks() { - var model = new MinimumConfig + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() { + AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + 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, }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + value.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void NewMaximumValidationWorks() { - var model = new MinimumConfig + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() { - MinimumAmount = "minimum_amount", + 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(); + } - // Null should be interpreted as omitted for these properties - Prorated = null, + [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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class MinimumConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewMinimumSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplaceAdjustmentAdjustment value = new Models::NewMinimum() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8875,24 +16961,30 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewMaximumSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplaceAdjustmentAdjustment value = new Models::NewMaximum() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8901,122 +16993,173 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class ReplacePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new ReplacePrice { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + LicenseAllocationPrice = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ApiEnum expectedCadence = PercentCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); - string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_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.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.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } + 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", + }, + }; - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Percent + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = new() { - Cadence = PercentCadence.Annual, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", - PercentConfig = new(0), + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9045,25 +17188,18 @@ 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); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Percent + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() { - Cadence = PercentCadence.Annual, + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", - PercentConfig = new(0), + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9084,101 +17220,330 @@ public void FieldRoundtripThroughSerialization_Works() DimensionalPriceGroupID = "dimensional_price_group_id", ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExternalPriceID = "external_price_id", + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", }, - 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; - 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() + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }; - 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.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.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 + ReplacePriceLicenseAllocationPrice expectedLicenseAllocationPrice = new() { - Cadence = PercentCadence.Annual, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", - PercentConfig = new(0), + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9202,364 +17567,401 @@ public void Validation_Works() ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Percent - { - Cadence = PercentCadence.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.Metadata); - Assert.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", - Name = "Annual fee", - PercentConfig = new(0), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Percent - { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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 Percent + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() { - Cadence = PercentCadence.Annual, + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", - PercentConfig = new(0), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - 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); + 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 InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var model = new 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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", + }, + }; - Assert.Equal(value, deserialized); + model.Validate(); } -} -public class PercentConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PercentConfig { Percent = 0 }; - - double expectedPercent = 0; + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - Assert.Equal(expectedPercent, model.Percent); + 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 SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PercentConfig { Percent = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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); - } + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", - [Fact] - public void Validation_Works() - { - var model = new PercentConfig { Percent = 0 }; + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; - model.Validate(); + 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")); } -} -public class PercentConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + var model = new ReplacePrice { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredValidationWorks() + public void CopyConstructor_Works() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplacePrice { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = 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() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, - ] - ), - }; - 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( + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ] - ), + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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", + }, + 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(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputTest : TestBase +public class ReplacePriceLicenseAllocationPriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9588,20 +17990,31 @@ 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() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = + ReplacePriceLicenseAllocationPriceModelType.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() @@ -9610,7 +18023,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9631,14 +18044,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(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(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); @@ -9650,6 +18069,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,17 +18084,22 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9703,12 +18128,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 ); @@ -9719,17 +18145,22 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9758,27 +18189,38 @@ 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() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = + ReplacePriceLicenseAllocationPriceModelType.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() @@ -9787,7 +18229,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9808,53 +18250,300 @@ 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - 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.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.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(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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + 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 ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPrice + { + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + 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 ReplacePriceLicenseAllocationPrice { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = ReplacePriceLicenseAllocationPriceCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ReplacePriceLicenseAllocationPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9883,213 +18572,263 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - model.Validate(); + ReplacePriceLicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePriceLicenseAllocationPriceCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Custom)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceCadence 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 EventOutput + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Annual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.SemiAnnual)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Monthly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Quarterly)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.OneTime)] + [InlineData(ReplacePriceLicenseAllocationPriceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePriceLicenseAllocationPriceLicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + WriteOffOverage = 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.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; + + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", + }; - 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.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + Amount = "amount", + Currency = "currency", - 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, + WriteOffOverage = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + ReplacePriceLicenseAllocationPriceLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } } -public class EventOutputCadenceTest : TestBase +public class ReplacePriceLicenseAllocationPriceModelTypeTest : 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(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceModelType 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(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceModelType 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); } @@ -10097,1151 +18836,2014 @@ public void SerializationRoundtrip_Works(EventOutputCadence 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 EventOutputConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceConversionRateConfigTest : TestBase { [Fact] - public void FieldRoundtrip_Works() + public void UnitValidationWorks() { - 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); + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void TieredValidationWorks() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + 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 TieredSerializationRoundtripWorks() { - 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); + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + Assert.Equal(value, deserialized); + } +} - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); +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 Validation_Works() + public void NewPlanTieredValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanBulkValidationWorks() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void BulkWithFiltersValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + BulkWithFiltersConfig = new() + { + 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", }; - - 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 NewPlanPackageValidationWorks() { - var model = new EventOutputConfig + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class EventOutputConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewPlanMatrixValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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 TieredValidationWorks() + public void NewPlanThresholdTotalAmountValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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 UnitSerializationRoundtripWorks() + public void NewPlanTieredPackageValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewPlanTieredWithMinimumValidationWorks() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = [ new() { - FirstUnit = 0, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", UnitAmount = "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")); + 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 OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanGroupedTieredValidationWorks() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - var model = new RemoveAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanPackageWithAllocationValidationWorks() { - var model = new RemoveAdjustment + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class RemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanUnitWithPercentValidationWorks() { - 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); + 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 SerializationRoundtrip_Works() + public void NewPlanMatrixWithAllocationValidationWorks() { - 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); + 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 FieldRoundtripThroughSerialization_Works() + public void MatrixWithThresholdDiscountsValidationWorks() { - 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); + ReplacePricePrice value = new ReplacePricePriceMatrixWithThresholdDiscounts() + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void Validation_Works() + public void TieredWithProrationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - model.Validate(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewPlanUnitWithProrationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + 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 OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanGroupedAllocationValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; - - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanBulkWithProrationValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanGroupedWithMeteredMinimumValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], - 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"], + 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", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - 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, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - 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 = + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + { + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }, ], - 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"], + 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", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanGroupedTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + 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", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - ReplacesAdjustmentID = "replaces_adjustment_id", + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + DimensionValues = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewMinimumValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void MeteredAllowanceValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; 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() + public void NewPlanMinimumCompositeValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewUsageDiscountFilterField.PriceID, - Operator = Models::NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewUsageDiscountPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewAmountDiscountSerializationRoundtripWorks() + public void PercentValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new ReplacePricePricePercent() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewAmountDiscountFilterField.PriceID, - Operator = Models::NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::PriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewMinimumSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewMinimumFilterField.PriceID, - Operator = Models::NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMinimumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 NewMaximumSerializationRoundtripWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = Models::NewMaximumFilterField.PriceID, - Operator = Models::NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewMaximumPriceType.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 = Models::NewBillingCycleConfigurationDurationUnit.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 ); Assert.Equal(value, deserialized); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanTieredSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Tiers = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Prorated = true, }, - 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, }, - }; - - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() + 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() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11270,206 +20872,143 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void BulkWithFiltersSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + BulkWithFiltersConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + 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( - 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 NewPlanPackageSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + 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() { - 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", + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = - Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - }; - - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + ExternalPriceID = "external_price_id", + 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() + 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::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanMatrixPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11498,159 +21037,166 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Prorate = true, }, - 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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")); - } - - [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, - PlanPhaseOrder = null, - Price = 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.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanTieredPackageSerializationRoundtripWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11679,34 +21225,37 @@ public void NewPlanUnitValidationWorks() 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 NewPlanTieredValidationWorks() + public void NewPlanGroupedTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { + GroupingKey = "x", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Prorated = true, }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11735,22 +21284,48 @@ public void NewPlanTieredValidationWorks() 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 NewPlanBulkValidationWorks() + public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + 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() @@ -11779,29 +21354,34 @@ public void NewPlanBulkValidationWorks() 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 BulkWithFiltersValidationWorks() + public void NewPlanPackageWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -11830,22 +21410,29 @@ public void BulkWithFiltersValidationWorks() 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 NewPlanPackageValidationWorks() + public void NewPlanUnitWithPercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11874,26 +21461,34 @@ public void NewPlanPackageValidationWorks() 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 NewPlanMatrixValidationWorks() + public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MatrixWithAllocationConfig = new() { + Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11923,30 +21518,53 @@ public void NewPlanMatrixValidationWorks() 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 NewPlanThresholdTotalAmountValidationWorks() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new ReplacePricePriceMatrixWithThresholdDiscounts() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - ConsumptionTable = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - Prorate = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11975,30 +21593,30 @@ public void NewPlanThresholdTotalAmountValidationWorks() 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 NewPlanTieredPackageValidationWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = ReplacePricePriceTieredWithProrationCadence.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" }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12027,41 +21645,29 @@ public void NewPlanTieredPackageValidationWorks() 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 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, - }, + 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() @@ -12090,29 +21696,33 @@ public void NewPlanTieredWithMinimumValidationWorks() 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 NewPlanGroupedTieredValidationWorks() + public void NewPlanGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanGroupedAllocationPriceCadence.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 = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12142,41 +21752,34 @@ public void NewPlanGroupedTieredValidationWorks() 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 NewPlanTieredPackageWithMinimumValidationWorks() + public void NewPlanBulkWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + 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::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.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() @@ -12205,27 +21808,35 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -12254,22 +21865,44 @@ public void NewPlanPackageWithAllocationValidationWorks() 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 NewPlanUnitWithPercentValidationWorks() + public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + 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::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12298,27 +21931,33 @@ public void NewPlanUnitWithPercentValidationWorks() 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 NewPlanMatrixWithAllocationValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.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 = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12348,23 +21987,41 @@ public void NewPlanMatrixWithAllocationValidationWorks() 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 TieredWithProrationValidationWorks() + public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + 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", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12393,22 +22050,38 @@ public void TieredWithProrationValidationWorks() 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 NewPlanUnitWithProrationValidationWorks() + public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + 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::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12437,26 +22110,37 @@ public void NewPlanUnitWithProrationValidationWorks() 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 NewPlanGroupedAllocationValidationWorks() + public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.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 = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12486,27 +22170,46 @@ public void NewPlanGroupedAllocationValidationWorks() 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 NewPlanBulkWithProrationValidationWorks() + public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -12535,28 +22238,48 @@ public void NewPlanBulkWithProrationValidationWorks() 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 NewPlanGroupedWithProratedMinimumValidationWorks() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -12585,36 +22308,40 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() 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 NewPlanGroupedWithMeteredMinimumValidationWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + DimensionValues = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], + Group = "group", }, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12644,24 +22371,31 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() 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 GroupedWithMinMaxThresholdsValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -12693,33 +22427,34 @@ public void GroupedWithMinMaxThresholdsValidationWorks() 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 NewPlanMatrixWithDisplayNameValidationWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12749,30 +22484,35 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() 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 NewPlanGroupedTieredPackageValidationWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12802,30 +22542,28 @@ public void NewPlanGroupedTieredPackageValidationWorks() 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 NewPlanMaxGroupTieredPackageValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.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, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12855,38 +22593,28 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() 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 NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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", - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12915,41 +22643,33 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() 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 NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = 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", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12978,33 +22698,38 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() 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); } +} +public class ReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + BulkWithFiltersConfig = new() { - DimensionValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Group = "group", }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13034,25 +22759,101 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + 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 CumulativeGroupedAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -13083,20 +22884,36 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceMinimumCadence.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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13126,21 +22943,112 @@ public void MinimumValidationWorks() 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); + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + 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 NewPlanMinimumCompositeValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanMinimumCompositePriceCadence.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", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13170,175 +23078,203 @@ public void NewPlanMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new ReplacePricePricePercent() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", }; - 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 EventOutputValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + BulkWithFiltersConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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(); + + model.Validate(); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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() + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + 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 NewPlanTieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + BulkWithFiltersConfig = new() { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Prorated = true, }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13367,662 +23303,561 @@ 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( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [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 + { + 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 NewPlanBulkSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - BulkWithFiltersConfig = new() - { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + 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 NewPlanPackageSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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() + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + ReplacePricePriceBulkWithFiltersConversionRateConfig 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsTest : TestBase +{ [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14052,29 +23887,143 @@ 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 + + ApiEnum expectedCadence = + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14103,28 +24052,55 @@ 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 - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14153,32 +24129,153 @@ 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 + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14208,88 +24305,287 @@ 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 - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14319,792 +24615,1049 @@ 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 + + ReplacePricePriceMatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue) + { + // force 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(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() - { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - 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 - ); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - Assert.Equal(value, deserialized); + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() - { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Dimension = "dimension", - UnitAmounts = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - DimensionValue = "dimension_value", - DisplayName = "display_name", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - 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 - ); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() - { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() - { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { + DefaultUnitAmount = "default_unit_amount", FirstDimension = "first_dimension", - MatrixScalingFactors = + MatrixValues = [ new() { FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", + UnitAmount = "unit_amount", 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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 - ); + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], - Assert.Equal(value, deserialized); + SecondDimension = null, + }; + + model.Validate(); } [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() - { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { + DefaultUnitAmount = "default_unit_amount", FirstDimension = "first_dimension", - MatrixScalingFactors = + MatrixValues = [ new() { FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", + UnitAmount = "unit_amount", SecondDimensionValue = "second_dimension_value", }, ], - Tiers = + SecondDimension = "second_dimension", + ThresholdDiscountGroups = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - 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 - ); + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; - Assert.Equal(value, deserialized); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - 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 - ); + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", - Assert.Equal(value, deserialized); + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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 + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } - Assert.Equal(value, deserialized); + [Fact] + public void Validation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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 - ); + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", - Assert.Equal(value, deserialized); + Description = null, + }; + + model.Validate(); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void CopyConstructor_Works() { - 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() + var model = + new ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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); + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() + { + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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() - { - 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 EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceBulkWithFiltersTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15133,24 +25686,18 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -15159,7 +25706,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15180,14 +25727,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); @@ -15199,6 +25747,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -15208,25 +25757,19 @@ public void FieldRoundtrip_Works() 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, + } + + [Fact] + public void SerializationRoundtrip_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() @@ -15255,12 +25798,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 ); @@ -15271,20 +25815,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15313,31 +25851,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); - 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 = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -15346,7 +25878,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15367,14 +25899,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); @@ -15389,6 +25922,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25937,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = 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() @@ -15445,6 +25973,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 +25984,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -15493,6 +26016,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26027,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -15524,20 +26043,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - 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 = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -15550,6 +26063,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15576,6 +26090,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -15583,266 +26099,181 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new ReplacePricePriceTieredWithProration { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new ReplacePricePriceTieredWithProration { - PropertyKey = "x", - PropertyValue = "x", + 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + ReplacePricePriceTieredWithProration copied = new(model); - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +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) { - 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); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + [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) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 ); @@ -15853,158 +26284,150 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - model.Validate(); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) + [Fact] + public void Validation_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); + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16016,7 +26439,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16037,7 +26460,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16045,7 +26468,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16056,7 +26479,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16073,7 +26496,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16082,19 +26505,23 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26550,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 = - ReplacePricePriceTieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26578,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16163,14 +26599,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( + 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); @@ -16182,6 +26622,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26637,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26677,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 +26694,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26734,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26769,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16331,14 +26790,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( + 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); @@ -16353,6 +26816,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26831,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26871,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 +26882,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -16445,6 +26918,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26929,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16470,14 +26949,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16490,6 +26973,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16516,6 +27000,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27011,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16545,27 +27035,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 ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : 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) + [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(); } @@ -16573,7 +27117,7 @@ public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValu public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -16581,20 +27125,22 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + 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); @@ -16604,50 +27150,58 @@ public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCad 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 ); @@ -16658,123 +27212,75 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - model.Validate(); - } -} - -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); + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; - model.Validate(); + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new( + model + ); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16786,7 +27292,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16807,7 +27313,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16815,7 +27321,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16826,7 +27332,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16843,7 +27349,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16852,20 +27358,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -16897,23 +27403,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 = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -16924,7 +27431,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16945,13 +27452,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -16967,6 +27475,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,15 +27490,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17021,12 +27530,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,15 +27547,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17077,30 +27587,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 = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17111,7 +27622,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17132,13 +27643,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17157,6 +27669,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,15 +27684,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17211,6 +27724,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17221,15 +27735,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17257,6 +27771,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +27782,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17286,15 +27802,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17310,6 +27826,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17336,6 +27853,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +27864,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -17369,27 +27888,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 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 ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : 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(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(); } @@ -17397,7 +27970,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 +27978,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + 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); @@ -17430,58 +28003,58 @@ 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 +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17493,55 +28066,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17553,7 +28145,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17574,7 +28166,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17582,7 +28174,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17593,7 +28185,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17610,7 +28202,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17619,20 +28211,21 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17664,24 +28257,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 = + ReplacePricePriceDailyCreditAllowanceCadence.Annual; + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -17691,7 +28284,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17712,14 +28305,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -17734,6 +28325,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +28340,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17788,12 +28381,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 +28398,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17844,31 +28439,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 = + ReplacePricePriceDailyCreditAllowanceCadence.Annual; + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -17878,7 +28473,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17899,14 +28494,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -17924,6 +28517,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +28532,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -17978,6 +28573,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 +28584,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18024,6 +28621,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28632,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18053,15 +28653,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -18077,6 +28678,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18103,6 +28705,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,51 +28716,107 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceDailyCreditAllowance { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 ReplacePricePriceDailyCreditAllowance + { + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::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 = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - model.Validate(); + ReplacePricePriceDailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceCadenceTest : 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(ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Custom)] + public void Validation_Works(ReplacePricePriceDailyCreditAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18164,7 +28824,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 +28832,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue - ) + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceDailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceDailyCreditAllowanceCadence 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 +28855,189 @@ 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 ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18259,56 +29048,66 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = new( + model + ); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18320,7 +29119,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18341,7 +29140,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18349,7 +29148,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18360,7 +29159,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18377,7 +29176,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18386,16 +29185,24 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18425,19 +29232,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 = + ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18447,7 +29260,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18468,12 +29281,13 @@ 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(expectedMinimumConfig, model.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18487,6 +29301,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +29316,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18535,12 +29358,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 +29375,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18585,26 +29417,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 = + ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18614,7 +29452,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18635,12 +29473,13 @@ 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(expectedMinimumConfig, deserialized.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18657,6 +29496,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +29511,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18705,6 +29553,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 +29564,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -18745,6 +29602,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29613,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -18768,11 +29635,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -18786,6 +29661,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18812,6 +29688,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29699,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceMeteredAllowance { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -18839,57 +29725,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 ReplacePricePriceMeteredAllowance + { + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceMeteredAllowanceCadenceTest : 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(ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Custom)] + public void Validation_Works(ReplacePricePriceMeteredAllowanceCadence 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(ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(ReplacePricePriceMeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceMeteredAllowanceCadence 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 +29839,67 @@ 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 ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18950,33 +29907,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -18985,16 +29959,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -19002,39 +29990,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19046,7 +30062,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19067,17 +30083,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new 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 +30102,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19101,10 +30118,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 +30167,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 +30207,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 +30227,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +30276,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 +30327,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 +30374,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 +30397,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +30446,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 +30487,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30530,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19528,6 +30557,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30586,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 +30756,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 +30893,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 +30938,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 +30958,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +31012,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 +31068,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 +31120,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 +31143,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +31197,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 +31243,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31296,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20223,6 +31323,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31357,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 +31610,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..ccdc8a351 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs @@ -32,11 +32,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/versions/version" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/versions/version" + ), + 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..09ea64225 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs @@ -32,11 +32,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/set_default_version" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/plans/external_plan_id/external_plan_id/set_default_version" + ), + 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..c0126fbd0 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() @@ -120,6 +121,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -167,6 +169,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 +265,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -277,6 +286,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -324,6 +334,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 +455,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -459,6 +476,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -506,6 +524,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 +635,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -631,6 +656,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -678,6 +704,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 +807,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -795,6 +828,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -842,6 +876,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 +997,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -977,6 +1018,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1024,6 +1066,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 +1079,182 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..ebf1c7f96 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() @@ -286,6 +287,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -333,6 +335,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 +688,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -702,6 +711,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -749,6 +759,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 +1113,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1118,6 +1135,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1165,6 +1183,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 +1534,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1531,6 +1556,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1578,6 +1604,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 +1985,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1975,6 +2008,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2022,6 +2056,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 +2409,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2391,6 +2432,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2438,6 +2480,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 +2849,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2823,6 +2872,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2870,6 +2920,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 +3273,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3239,6 +3296,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3286,6 +3344,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 +3705,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3662,6 +3727,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3709,6 +3775,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 +4126,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4075,6 +4148,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4122,6 +4196,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 +4577,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4519,6 +4600,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4566,6 +4648,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 +5001,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4935,6 +5024,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4982,6 +5072,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 +5179,991 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +6176,658 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +6836,342 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +7346,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6037,6 +7367,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6084,6 +7415,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 +7518,343 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +7863,443 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +8474,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7147,6 +8495,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7194,6 +8543,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 +8646,9 @@ public void Validation_Works() WillAutoIssue = true, }; - model.Validate(); + Models::CreatedInvoice copied = new(model); + + Assert.Equal(model, copied); } } @@ -7385,6 +8742,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 +8855,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 +8885,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 +9025,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 +9328,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7934,6 +9349,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7981,6 +9397,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 +9510,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8108,6 +9531,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8155,6 +9579,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 +9734,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8324,6 +9755,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8371,6 +9803,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 +9932,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8514,6 +9953,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8561,6 +10001,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 +10121,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8695,6 +10142,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8742,6 +10190,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 +10345,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8911,6 +10366,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8958,6 +10414,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 +10451,200 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +11179,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..46e15be2a 100644 --- a/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/coupons/coupon_id/archive"), url); + Assert.True( + TestBase.UrisEqual(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..a4dcfb679 100644 --- a/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs @@ -73,7 +73,23 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/coupons"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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..7d966c589 100644 --- a/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/coupons/coupon_id"), url); + Assert.True( + TestBase.UrisEqual(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..282ceb836 100644 --- a/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs @@ -104,11 +104,29 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/coupons?cursor=cursor&limit=1&redemption_code=redemption_code&show_archived=true" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/coupons?cursor=cursor&limit=1&redemption_code=redemption_code&show_archived=true" + ), + 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..51d148f12 100644 --- a/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs @@ -85,11 +85,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/coupons/coupon_id/subscriptions?cursor=cursor&limit=1" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/coupons/coupon_id/subscriptions?cursor=cursor&limit=1" + ), + 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..fb9b916ac 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/credit_blocks/block_id"), url); + Assert.True( + TestBase.UrisEqual(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..904d15298 --- /dev/null +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockListInvoicesParamsTest.cs @@ -0,0 +1,42 @@ +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.True( + TestBase.UrisEqual( + 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..f64e69991 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/credit_blocks/block_id"), url); + Assert.True( + TestBase.UrisEqual(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..f1174be67 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs @@ -132,7 +132,33 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/credit_notes"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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..23d62c111 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs @@ -22,6 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/credit_notes/credit_note_id"), url); + Assert.True( + TestBase.UrisEqual( + 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..d7d867dbc 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs @@ -115,6 +115,31 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { CreditNoteListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + Limit = 1, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/credit_notes?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" + ), + 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"), @@ -124,13 +149,8 @@ public void Url_Works() Limit = 1, }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + CreditNoteListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/credit_notes?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" - ), - url - ); + 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..8290ec290 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 @@ -119,9 +134,9 @@ public class CountryTest : TestBase [InlineData(Country.Co)] [InlineData(Country.Cr)] [InlineData(Country.Cv)] - [InlineData(Country.De)] [InlineData(Country.Cy)] [InlineData(Country.Cz)] + [InlineData(Country.De)] [InlineData(Country.Dk)] [InlineData(Country.Do)] [InlineData(Country.Ec)] @@ -131,9 +146,11 @@ public class CountryTest : TestBase [InlineData(Country.Et)] [InlineData(Country.Eu)] [InlineData(Country.Fi)] + [InlineData(Country.Fo)] [InlineData(Country.Fr)] [InlineData(Country.GB)] [InlineData(Country.Ge)] + [InlineData(Country.Gi)] [InlineData(Country.Gn)] [InlineData(Country.Gr)] [InlineData(Country.Hk)] @@ -153,6 +170,7 @@ public class CountryTest : TestBase [InlineData(Country.Kz)] [InlineData(Country.La)] [InlineData(Country.Li)] + [InlineData(Country.Lk)] [InlineData(Country.Lt)] [InlineData(Country.Lu)] [InlineData(Country.Lv)] @@ -174,6 +192,7 @@ public class CountryTest : TestBase [InlineData(Country.Ph)] [InlineData(Country.Pl)] [InlineData(Country.Pt)] + [InlineData(Country.Py)] [InlineData(Country.Ro)] [InlineData(Country.Rs)] [InlineData(Country.Ru)] @@ -251,9 +270,9 @@ public void InvalidEnumValidationThrows_Works() [InlineData(Country.Co)] [InlineData(Country.Cr)] [InlineData(Country.Cv)] - [InlineData(Country.De)] [InlineData(Country.Cy)] [InlineData(Country.Cz)] + [InlineData(Country.De)] [InlineData(Country.Dk)] [InlineData(Country.Do)] [InlineData(Country.Ec)] @@ -263,9 +282,11 @@ public void InvalidEnumValidationThrows_Works() [InlineData(Country.Et)] [InlineData(Country.Eu)] [InlineData(Country.Fi)] + [InlineData(Country.Fo)] [InlineData(Country.Fr)] [InlineData(Country.GB)] [InlineData(Country.Ge)] + [InlineData(Country.Gi)] [InlineData(Country.Gn)] [InlineData(Country.Gr)] [InlineData(Country.Hk)] @@ -285,6 +306,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(Country.Kz)] [InlineData(Country.La)] [InlineData(Country.Li)] + [InlineData(Country.Lk)] [InlineData(Country.Lt)] [InlineData(Country.Lu)] [InlineData(Country.Lv)] @@ -306,6 +328,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(Country.Ph)] [InlineData(Country.Pl)] [InlineData(Country.Pt)] + [InlineData(Country.Py)] [InlineData(Country.Ro)] [InlineData(Country.Rs)] [InlineData(Country.Ru)] @@ -411,8 +434,10 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.EsCif)] [InlineData(CustomerTaxIDType.EtTin)] [InlineData(CustomerTaxIDType.EuOssVat)] + [InlineData(CustomerTaxIDType.FoVat)] [InlineData(CustomerTaxIDType.GBVat)] [InlineData(CustomerTaxIDType.GeVat)] + [InlineData(CustomerTaxIDType.GiTin)] [InlineData(CustomerTaxIDType.GnNif)] [InlineData(CustomerTaxIDType.HkBr)] [InlineData(CustomerTaxIDType.HrOib)] @@ -421,6 +446,7 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.IlVat)] [InlineData(CustomerTaxIDType.InGst)] [InlineData(CustomerTaxIDType.IsVat)] + [InlineData(CustomerTaxIDType.ItCf)] [InlineData(CustomerTaxIDType.JpCn)] [InlineData(CustomerTaxIDType.JpRn)] [InlineData(CustomerTaxIDType.JpTrn)] @@ -432,6 +458,7 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.LaTin)] [InlineData(CustomerTaxIDType.LiUid)] [InlineData(CustomerTaxIDType.LiVat)] + [InlineData(CustomerTaxIDType.LkVat)] [InlineData(CustomerTaxIDType.MaVat)] [InlineData(CustomerTaxIDType.MdVat)] [InlineData(CustomerTaxIDType.MePib)] @@ -449,6 +476,8 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] + [InlineData(CustomerTaxIDType.PyRuc)] [InlineData(CustomerTaxIDType.RoTin)] [InlineData(CustomerTaxIDType.RsPib)] [InlineData(CustomerTaxIDType.RuInn)] @@ -541,8 +570,10 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.EsCif)] [InlineData(CustomerTaxIDType.EtTin)] [InlineData(CustomerTaxIDType.EuOssVat)] + [InlineData(CustomerTaxIDType.FoVat)] [InlineData(CustomerTaxIDType.GBVat)] [InlineData(CustomerTaxIDType.GeVat)] + [InlineData(CustomerTaxIDType.GiTin)] [InlineData(CustomerTaxIDType.GnNif)] [InlineData(CustomerTaxIDType.HkBr)] [InlineData(CustomerTaxIDType.HrOib)] @@ -551,6 +582,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.IlVat)] [InlineData(CustomerTaxIDType.InGst)] [InlineData(CustomerTaxIDType.IsVat)] + [InlineData(CustomerTaxIDType.ItCf)] [InlineData(CustomerTaxIDType.JpCn)] [InlineData(CustomerTaxIDType.JpRn)] [InlineData(CustomerTaxIDType.JpTrn)] @@ -562,6 +594,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.LaTin)] [InlineData(CustomerTaxIDType.LiUid)] [InlineData(CustomerTaxIDType.LiVat)] + [InlineData(CustomerTaxIDType.LkVat)] [InlineData(CustomerTaxIDType.MaVat)] [InlineData(CustomerTaxIDType.MdVat)] [InlineData(CustomerTaxIDType.MePib)] @@ -579,6 +612,8 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] + [InlineData(CustomerTaxIDType.PyRuc)] [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..0ec8355a3 100644 --- a/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs +++ b/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs @@ -1,5 +1,6 @@ using System.Text.Json; using Orb.Core; +using Orb.Exceptions; using Orb.Models.Customers; namespace Orb.Tests.Models.Customers; @@ -12,11 +13,12 @@ public void FieldRoundtrip_Works() var model = new AccountingProviderConfig { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }; string expectedExternalProviderID = "external_provider_id"; - string expectedProviderType = "provider_type"; + ApiEnum expectedProviderType = + AccountingProviderConfigProviderType.Quickbooks; Assert.Equal(expectedExternalProviderID, model.ExternalProviderID); Assert.Equal(expectedProviderType, model.ProviderType); @@ -28,7 +30,7 @@ public void SerializationRoundtrip_Works() var model = new AccountingProviderConfig { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -46,7 +48,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new AccountingProviderConfig { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -57,7 +59,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedExternalProviderID = "external_provider_id"; - string expectedProviderType = "provider_type"; + ApiEnum expectedProviderType = + AccountingProviderConfigProviderType.Quickbooks; Assert.Equal(expectedExternalProviderID, deserialized.ExternalProviderID); Assert.Equal(expectedProviderType, deserialized.ProviderType); @@ -69,9 +72,77 @@ public void Validation_Works() var model = new AccountingProviderConfig { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingProviderConfig + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, + }; + + AccountingProviderConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class AccountingProviderConfigProviderTypeTest : TestBase +{ + [Theory] + [InlineData(AccountingProviderConfigProviderType.Quickbooks)] + [InlineData(AccountingProviderConfigProviderType.Netsuite)] + public void Validation_Works(AccountingProviderConfigProviderType rawValue) + { + // force 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(AccountingProviderConfigProviderType.Quickbooks)] + [InlineData(AccountingProviderConfigProviderType.Netsuite)] + public void SerializationRoundtrip_Works(AccountingProviderConfigProviderType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.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/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..b697df7e2 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs @@ -73,11 +73,29 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/customers/customer_id/balance_transactions"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/customers/customer_id/balance_transactions"), + 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..6b9ac64a3 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs @@ -121,6 +121,32 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { BalanceTransactionListParams parameters = new() + { + CustomerID = "customer_id", + Cursor = "cursor", + Limit = 1, + OperationTimeGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + OperationTimeGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + OperationTimeLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + OperationTimeLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/balance_transactions?cursor=cursor&limit=1&operation_time%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BalanceTransactionListParams { CustomerID = "customer_id", Cursor = "cursor", @@ -131,13 +157,8 @@ public void Url_Works() OperationTimeLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + BalanceTransactionListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/balance_transactions?cursor=cursor&limit=1&operation_time%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&operation_time%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00" - ), - url - ); + 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..02f0c49ef 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs @@ -82,20 +82,39 @@ public void Url_Works() { ExternalCustomerID = "external_customer_id", Currency = "currency", - TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), - TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00.000+00:00"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00.000+00:00"), ViewMode = CostListByExternalIDParamsViewMode.Periodic, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00%2b00%3a00&view_mode=periodic" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00.000%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00.000%2b00%3a00&view_mode=periodic" + ), + 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..e1c7aa819 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() @@ -88,6 +89,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -135,6 +137,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 +212,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -224,6 +233,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -271,6 +281,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 +367,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -371,6 +388,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -418,6 +436,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 +525,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -521,6 +546,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -568,6 +594,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 +676,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -664,6 +697,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -711,6 +745,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 +831,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -811,6 +852,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -858,6 +900,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 +923,158 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..9a23402ce 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs @@ -78,20 +78,39 @@ public void Url_Works() { CustomerID = "customer_id", Currency = "currency", - TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), - TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00.000+00:00"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00.000+00:00"), ViewMode = ViewMode.Periodic, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00%2b00%3a00&view_mode=periodic" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00.000%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00.000%2b00%3a00&view_mode=periodic" + ), + 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..0b9d288ab 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() @@ -88,6 +89,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -135,6 +137,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 +212,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -224,6 +233,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -271,6 +281,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 +367,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -371,6 +388,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -418,6 +436,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 +525,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -521,6 +546,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -568,6 +594,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 +676,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -664,6 +697,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -711,6 +745,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 +831,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -811,6 +852,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -858,6 +900,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 +923,158 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..06798c14a 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,17 +149,44 @@ public void Url_Works() ExternalCustomerID = "external_customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), IncludeAllBlocks = true, Limit = 1, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - 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" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "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..24cecf4db 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,17 +149,44 @@ public void Url_Works() CustomerID = "customer_id", Currency = "currency", Cursor = "cursor", + EffectiveDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + EffectiveDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), IncludeAllBlocks = true, Limit = 1, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/credits?currency=currency&cursor=cursor&include_all_blocks=true&limit=1" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "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..c0d3786a1 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() @@ -240,6 +241,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -287,6 +289,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 +601,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -614,6 +623,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -661,6 +671,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 +1010,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1016,6 +1033,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1063,6 +1081,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 +1403,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1401,6 +1426,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1448,6 +1474,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 +1793,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1782,6 +1815,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1829,6 +1863,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 +2202,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2184,6 +2225,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2231,6 +2273,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 +2534,395 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..629ec3f4f 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, @@ -124,13 +127,59 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/ledger_entry" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/ledger_entry" + ), + 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 +211,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 +311,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 +443,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 +474,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 +532,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 +577,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 +616,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 +674,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 +771,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 +911,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 +1057,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 +1069,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 +1078,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 +1093,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 +1118,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 +1138,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 +1147,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 +1162,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 +1184,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 +1219,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 +1242,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1129,6 +1255,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1150,6 +1277,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1162,6 +1290,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1189,6 +1318,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1200,6 +1330,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 +1614,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 +1842,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 +2057,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 +2311,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..f30af7083 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() @@ -239,6 +240,7 @@ public void IncrementLedgerEntryValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -286,6 +288,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 +828,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -842,6 +851,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -889,6 +899,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..bd4d7abbb 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, @@ -120,11 +123,56 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/customers/customer_id/credits/ledger_entry"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/customers/customer_id/credits/ledger_entry"), + 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 +202,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 +296,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 +423,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 +453,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 +510,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 +553,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 +590,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 +647,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 +744,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 +871,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 +1013,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 +1023,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 +1032,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 +1047,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 +1071,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 +1088,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 +1097,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 +1112,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 +1134,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 +1169,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 +1192,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1081,6 +1205,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1102,6 +1227,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1114,6 +1240,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1141,6 +1268,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1152,6 +1280,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 +1548,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 +1768,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 +1973,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 +2219,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..1d3bf2a03 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() @@ -239,6 +240,7 @@ public void IncrementLedgerEntryValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -286,6 +288,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 +828,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -842,6 +851,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -889,6 +899,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..8174ca098 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() @@ -261,6 +262,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -317,6 +319,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 +640,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -659,6 +668,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -713,6 +723,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 +1068,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1079,6 +1096,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1135,6 +1153,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 +1496,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1499,6 +1524,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1555,6 +1581,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 +1909,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1904,6 +1937,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1958,6 +1992,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 +2337,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2324,6 +2365,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2380,6 +2422,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 +2533,428 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..cc5ff622c 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs @@ -170,6 +170,36 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { LedgerListByExternalIDParams parameters = new() + { + ExternalCustomerID = "external_customer_id", + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Currency = "currency", + Cursor = "cursor", + EntryStatus = LedgerListByExternalIDParamsEntryStatus.Committed, + EntryType = LedgerListByExternalIDParamsEntryType.Increment, + Limit = 1, + MinimumAmount = "minimum_amount", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/ledger?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00¤cy=currency&cursor=cursor&entry_status=committed&entry_type=increment&limit=1&minimum_amount=minimum_amount" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LedgerListByExternalIDParams { ExternalCustomerID = "external_customer_id", CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -184,14 +214,9 @@ public void Url_Works() MinimumAmount = "minimum_amount", }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + LedgerListByExternalIDParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/ledger?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00¤cy=currency&cursor=cursor&entry_status=committed&entry_type=increment&limit=1&minimum_amount=minimum_amount" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponseTest.cs index 02da8c726..2d2ea01d6 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() @@ -239,6 +240,7 @@ public void IncrementLedgerEntryValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -286,6 +288,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 +828,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -842,6 +851,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -889,6 +899,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..e68238b64 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() @@ -261,6 +262,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -317,6 +319,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 +640,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -659,6 +668,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -713,6 +723,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 +1068,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1079,6 +1096,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1135,6 +1153,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 +1496,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1499,6 +1524,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1555,6 +1581,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 +1909,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1904,6 +1937,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1958,6 +1992,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 +2337,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2324,6 +2365,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2380,6 +2422,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 +2533,428 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..bf731b539 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs @@ -164,6 +164,36 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { LedgerListParams parameters = new() + { + CustomerID = "customer_id", + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Currency = "currency", + Cursor = "cursor", + EntryStatus = EntryStatus.Committed, + EntryType = EntryType.Increment, + Limit = 1, + MinimumAmount = "minimum_amount", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/credits/ledger?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00¤cy=currency&cursor=cursor&entry_status=committed&entry_type=increment&limit=1&minimum_amount=minimum_amount" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LedgerListParams { CustomerID = "customer_id", CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -178,14 +208,9 @@ public void Url_Works() MinimumAmount = "minimum_amount", }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + LedgerListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/credits/ledger?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00¤cy=currency&cursor=cursor&entry_status=committed&entry_type=increment&limit=1&minimum_amount=minimum_amount" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListResponseTest.cs index 1ea27aa29..b15cbb597 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() @@ -239,6 +240,7 @@ public void IncrementLedgerEntryValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -286,6 +288,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 +828,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -842,6 +851,7 @@ public void IncrementLedgerEntrySerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -889,6 +899,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..0b9d07b15 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs @@ -137,13 +137,42 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups" + ), + 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 +379,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..43fc8bae4 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs @@ -136,11 +136,40 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/customers/customer_id/credits/top_ups"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/customers/customer_id/credits/top_ups"), + 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 +376,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..6d80c0ca5 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs @@ -32,11 +32,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups/top_up_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups/top_up_id" + ), + 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..6dae26e81 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs @@ -28,9 +28,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/customers/customer_id/credits/top_ups/top_up_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/credits/top_ups/top_up_id" + ), + 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..ad3f80208 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs @@ -93,11 +93,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups?cursor=cursor&limit=1" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/credits/top_ups?cursor=cursor&limit=1" + ), + 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..ef508fadf 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs @@ -85,11 +85,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/credits/top_ups?cursor=cursor&limit=1" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/credits/top_ups?cursor=cursor&limit=1" + ), + 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..5d23c250f 100644 --- a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs @@ -24,7 +24,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -57,6 +57,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -98,7 +99,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -131,6 +132,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -313,7 +315,92 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/customers"), url); + Assert.True(TestBase.UrisEqual(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 = AccountingProviderConfigProviderType.Quickbooks, + }, + ], + 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); } } @@ -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..5dd02a061 100644 --- a/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); + Assert.True( + TestBase.UrisEqual(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..82a2ca6be 100644 --- a/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id" + ), + 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..16b715ff3 100644 --- a/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); + Assert.True( + TestBase.UrisEqual(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..e1eb986d5 100644 --- a/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs @@ -115,6 +115,31 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { CustomerListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + Limit = 1, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" + ), + 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"), @@ -124,13 +149,8 @@ public void Url_Works() Limit = 1, }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + CustomerListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs index 84558ee8e..ee03b88cc 100644 --- a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/sync_payment_methods_from_gateway" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id/sync_payment_methods_from_gateway" + ), + 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..5ba049e12 100644 --- a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/customer_id/sync_payment_methods_from_gateway" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/customer_id/sync_payment_methods_from_gateway" + ), + 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..24f05daa9 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 @@ -1230,6 +1372,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1240,6 +1383,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1262,6 +1406,7 @@ public void SerializationRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1286,6 +1431,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1303,6 +1449,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1325,6 +1472,7 @@ public void Validation_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1374,6 +1522,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 +1553,7 @@ public void FieldRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1391,9 +1561,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 +1586,7 @@ public void SerializationRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1432,6 +1605,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1446,9 +1620,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 +1645,7 @@ public void Validation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1481,6 +1658,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -1493,6 +1671,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -1504,6 +1683,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 +1699,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 +1707,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 +1882,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..2d61fb20b 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs @@ -23,7 +23,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -98,7 +99,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -320,13 +322,101 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/customers/external_customer_id/external_customer_id" + ), + url + ) ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerUpdateByExternalIDParams + { + ID = "external_customer_id", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, + }, + ], + 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 +432,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -353,6 +444,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -376,6 +468,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -402,6 +495,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -421,6 +515,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -444,6 +539,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -493,6 +589,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 +622,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -512,9 +631,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 +657,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -556,6 +678,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -572,9 +695,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 +721,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -609,6 +735,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -622,6 +749,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -634,6 +762,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 +779,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 +787,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 +950,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 +975,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 +1323,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 +1459,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 +1595,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..3acce0429 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs @@ -23,7 +23,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -98,7 +99,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -320,7 +322,95 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); + Assert.True( + TestBase.UrisEqual(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 = AccountingProviderConfigProviderType.Quickbooks, + }, + ], + 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); } } @@ -337,6 +427,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -348,6 +439,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -371,6 +463,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -396,6 +489,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -414,6 +508,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -437,6 +532,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -486,6 +582,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 +615,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -505,9 +624,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 +650,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -549,6 +671,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -565,9 +688,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 +714,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -602,6 +728,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -615,6 +742,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -627,6 +755,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 +772,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 +780,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 +922,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 +947,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 +1277,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 +1411,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 +1545,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..10a30b506 100644 --- a/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs @@ -17,7 +17,7 @@ public void FieldRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -25,7 +25,11 @@ public void FieldRoundtrip_Works() List expectedAccountingProviders = [ - new() { ExternalProviderID = "external_provider_id", ProviderType = "provider_type" }, + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, + }, ]; bool expectedExcluded = true; @@ -48,7 +52,7 @@ public void SerializationRoundtrip_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -73,7 +77,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -88,7 +92,11 @@ public void FieldRoundtripThroughSerialization_Works() List expectedAccountingProviders = [ - new() { ExternalProviderID = "external_provider_id", ProviderType = "provider_type" }, + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, + }, ]; bool expectedExcluded = true; @@ -111,7 +119,7 @@ public void Validation_Works() new() { ExternalProviderID = "external_provider_id", - ProviderType = "provider_type", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, }, ], Excluded = true, @@ -165,4 +173,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAccountingSyncConfiguration + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderConfigProviderType.Quickbooks, + }, + ], + 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..d39d14ea7 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs @@ -92,6 +92,25 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/dimensional_price_groups"), url); + Assert.True( + TestBase.UrisEqual(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..9b48adccb 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs @@ -71,9 +71,23 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/dimensional_price_groups?cursor=cursor&limit=1"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/dimensional_price_groups?cursor=cursor&limit=1" + ), + 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..b00652de4 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/dimensional_price_groups/dimensional_price_group_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/dimensional_price_groups/dimensional_price_group_id" + ), + 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..601538cd5 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs @@ -76,11 +76,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/dimensional_price_groups/dimensional_price_group_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/dimensional_price_groups/dimensional_price_group_id" + ), + 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..d13187649 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs @@ -31,11 +31,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/dimensional_price_groups/external_dimensional_price_group_id/external_dimensional_price_group_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/dimensional_price_groups/external_dimensional_price_group_id/external_dimensional_price_group_id" + ), + 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..84cf42e76 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs @@ -79,11 +79,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/dimensional_price_groups/external_dimensional_price_group_id/external_dimensional_price_group_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/dimensional_price_groups/external_dimensional_price_group_id/external_dimensional_price_group_id" + ), + 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..c574f6b9f 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs @@ -22,6 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills/backfill_id/close"), url); + Assert.True( + TestBase.UrisEqual( + 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..ce5c3da2c 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs @@ -130,6 +130,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills"), url); + Assert.True( + TestBase.UrisEqual(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..68b1fa94f 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs @@ -22,6 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills/backfill_id"), url); + Assert.True( + TestBase.UrisEqual( + 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..f4e7bb76c 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs @@ -71,9 +71,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/events/backfills?cursor=cursor&limit=1"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/events/backfills?cursor=cursor&limit=1"), + 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..f2946a011 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs @@ -22,9 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/events/backfills/backfill_id/revert"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/events/backfills/backfill_id/revert"), + 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..e1c15a00c 100644 --- a/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/event_id/deprecate"), url); + Assert.True( + TestBase.UrisEqual(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..d21d27ce8 100644 --- a/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs @@ -198,11 +198,42 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/ingest?backfill_id=backfill_id&debug=true"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/ingest?backfill_id=backfill_id&debug=true"), + 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 +442,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..4c9855e31 100644 --- a/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs @@ -64,6 +64,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/search"), url); + Assert.True(TestBase.UrisEqual(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..4a4d5d714 100644 --- a/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs @@ -106,6 +106,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/events/event_id"), url); + Assert.True(TestBase.UrisEqual(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..d6bf5f79f 100644 --- a/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs @@ -96,19 +96,37 @@ public void Url_Works() { VolumeListParams parameters = new() { - TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), Cursor = "cursor", Limit = 1, - TimeframeEnd = DateTimeOffset.Parse("2024-10-11T06:00:00Z"), + TimeframeEnd = DateTimeOffset.Parse("2024-10-11T06:00:00.000+00:00"), }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/events/volume?timeframe_start=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1&timeframe_end=2024-10-11T06%3a00%3a00%2b00%3a00" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/events/volume?timeframe_start=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1&timeframe_end=2024-10-11T06%3a00%3a00.000%2b00%3a00" + ), + 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..b4b47264b 100644 --- a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs +++ b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs @@ -89,6 +89,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoice_line_items"), url); + Assert.True( + TestBase.UrisEqual(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..c13f519ac 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() @@ -114,6 +115,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -161,6 +163,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 +276,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -288,6 +297,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -335,6 +345,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 +500,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -504,6 +521,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -551,6 +569,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 +698,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -694,6 +719,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -741,6 +767,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 +887,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -875,6 +908,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -922,6 +956,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 +1111,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1091,6 +1132,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1138,6 +1180,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 +1217,200 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..735abd574 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() @@ -203,6 +204,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -250,6 +252,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 +528,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -540,6 +549,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -587,6 +597,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 +947,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -951,6 +968,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -998,6 +1016,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 +1299,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1295,6 +1320,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1342,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"), @@ -1619,6 +1651,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1639,6 +1672,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1686,6 +1720,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 +2070,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2050,6 +2091,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2097,6 +2139,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 +2244,357 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +2685,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 +2815,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 +2974,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 +3262,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2826,6 +3283,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2873,6 +3331,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 +3439,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2995,6 +3460,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3038,6 +3504,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 +3652,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3200,6 +3673,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3247,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"), @@ -3363,6 +3843,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3383,6 +3864,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3430,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"), @@ -3539,6 +4027,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3559,6 +4048,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3602,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"); @@ -3744,6 +4240,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3764,6 +4261,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3811,6 +4309,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 +4346,193 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +5065,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..634e9826c 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", @@ -327,7 +337,58 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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..a13c28e11 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs @@ -32,11 +32,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/invoices/invoice_id/invoice_line_items/line_item_id" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/invoices/invoice_id/invoice_line_items/line_item_id" + ), + 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..f5bd03b06 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id"), url); + Assert.True( + TestBase.UrisEqual(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..5d5231272 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs @@ -22,9 +22,23 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/invoices/upcoming?subscription_id=subscription_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/invoices/upcoming?subscription_id=subscription_id" + ), + 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..8efd08446 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() @@ -203,6 +204,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -250,6 +252,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 +528,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -540,6 +549,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -587,6 +597,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 +948,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -952,6 +969,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -999,6 +1017,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 +1303,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1299,6 +1324,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1346,6 +1372,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 +1655,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1643,6 +1676,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1690,6 +1724,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 +2075,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2055,6 +2096,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2102,6 +2144,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 +2250,357 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +2691,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 +2821,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 +2976,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 +3272,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2836,6 +3293,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2883,6 +3341,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 +3449,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3005,6 +3470,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3048,6 +3514,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 +3662,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3210,6 +3683,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3257,6 +3731,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 +3854,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3394,6 +3875,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3441,6 +3923,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 +4039,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3571,6 +4060,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3614,6 +4104,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 +4252,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3776,6 +4273,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3823,6 +4321,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 +4358,193 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +5077,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..8703a0cb7 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs @@ -48,6 +48,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/issue"), url); + Assert.True( + TestBase.UrisEqual(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..2b1bd7d2f --- /dev/null +++ b/src/Orb.Tests/Models/Invoices/InvoiceIssueSummaryParamsTest.cs @@ -0,0 +1,76 @@ +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.True( + TestBase.UrisEqual( + 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..77adbbecd 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() @@ -209,6 +210,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -256,6 +258,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 +537,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -549,6 +558,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -596,6 +606,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 +903,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -907,6 +924,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -954,6 +972,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 +1267,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1263,6 +1288,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1310,6 +1336,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 +1622,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1610,6 +1643,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1657,6 +1691,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 +1988,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1968,6 +2009,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2015,6 +2057,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 +2165,364 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..c63fa7b73 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs @@ -254,6 +254,44 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { InvoiceListParams parameters = new() + { + 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.117+00:00"), + InvoiceDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + IsRecurring = true, + Limit = 1, + Status = [Status.Draft], + SubscriptionID = "subscription_id", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/invoices?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" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceListParams { Amount = "amount", AmountGt = "amount[gt]", @@ -276,14 +314,9 @@ public void Url_Works() SubscriptionID = "subscription_id", }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + InvoiceListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/invoices?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" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs index 57c48cf0b..d435f593e 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryPageResponseTest.cs @@ -743,4 +743,127 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new InvoiceListSummaryPageResponse + { + Data = + [ + new() + { + ID = "id", + AmountDue = "8.00", + AutoCollection = new() + { + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNotes = + [ + new() + { + ID = "id", + CreditNoteNumber = "credit_note_number", + Memo = "memo", + Reason = "reason", + Total = "total", + Type = "type", + VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + }, + ], + Currency = "USD", + Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + CustomerBalanceTransactions = + [ + new() + { + ID = "cgZa3SXcsPTVyC4Y", + Action = + InvoiceListSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + Amount = "11.00", + CreatedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), + CreditNote = new("id"), + Description = "An optional description", + EndingBalance = "22.00", + Invoice = new("gXcsPTVyC4YZa3Sc"), + StartingBalance = "33.00", + Type = + InvoiceListSummaryResponseCustomerBalanceTransactionType.Increment, + }, + ], + CustomerTaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + DueDate = DateTimeOffset.Parse("2022-05-30T07:00:00+00:00"), + EligibleToIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + HostedInvoiceUrl = "hosted_invoice_url", + InvoiceDate = DateTimeOffset.Parse("2022-05-01T07:00:00+00:00"), + InvoiceNumber = "JYEFHK-00001", + InvoicePdf = + "https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + InvoiceSource = InvoiceListSummaryResponseInvoiceSource.Subscription, + IssueFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IssuedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Memo = "memo", + Metadata = new Dictionary() { { "foo", "string" } }, + PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentAttempts = + [ + new() + { + ID = "id", + Amount = "amount", + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentProvider = + InvoiceListSummaryResponsePaymentAttemptPaymentProvider.Stripe, + PaymentProviderID = "payment_provider_id", + ReceiptPdf = + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb", + Succeeded = true, + }, + ], + PaymentFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PaymentStartedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ScheduledIssueAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Status = InvoiceListSummaryResponseStatus.Issued, + Subscription = new("VDGsT23osdLb84KD"), + SyncFailedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Total = "8.00", + VoidedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + WillAutoIssue = true, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + InvoiceListSummaryPageResponse copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs index 60d010678..3b6e43c0a 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")); } @@ -266,6 +250,44 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { InvoiceListSummaryParams parameters = new() + { + 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.117+00:00"), + InvoiceDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + IsRecurring = true, + Limit = 1, + Status = InvoiceListSummaryParamsStatus.Draft, + SubscriptionID = "subscription_id", + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + 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=draft&subscription_id=subscription_id" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceListSummaryParams { Amount = "amount", AmountGt = "amount[gt]", @@ -284,19 +306,13 @@ 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", }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + InvoiceListSummaryParams copied = new(parameters); - 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" - ), - url - ); + Assert.Equal(parameters, copied); } } @@ -417,67 +433,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..569d39b33 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs @@ -71,6 +71,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/mark_paid"), url); + Assert.True( + TestBase.UrisEqual( + 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..121afb78a 100644 --- a/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs @@ -8,20 +8,46 @@ 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); + Assert.True( + TestBase.UrisEqual(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..fabcbbe6a 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); @@ -85,7 +93,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id"), url); + Assert.True( + TestBase.UrisEqual(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); } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs index 9f4ff4f43..3664312d5 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/void"), url); + Assert.True( + TestBase.UrisEqual(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..870ec16d9 100644 --- a/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id/archive"), url); + Assert.True( + TestBase.UrisEqual(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..14d1d2229 100644 --- a/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs @@ -59,6 +59,20 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/items"), url); + Assert.True(TestBase.UrisEqual(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..a5b648ad5 100644 --- a/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs @@ -22,6 +22,16 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id"), url); + Assert.True(TestBase.UrisEqual(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..4c544cb94 100644 --- a/src/Orb.Tests/Models/Items/ItemListParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemListParamsTest.cs @@ -71,6 +71,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/items?cursor=cursor&limit=1"), url); + Assert.True( + TestBase.UrisEqual( + 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..c7ffedc66 100644 --- a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs @@ -97,7 +97,30 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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..fcf06060c --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeCreateParamsTest.cs @@ -0,0 +1,39 @@ +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 = "x", Name = "x" }; + + string expectedGroupingKey = "x"; + string expectedName = "x"; + + Assert.Equal(expectedGroupingKey, parameters.GroupingKey); + Assert.Equal(expectedName, parameters.Name); + } + + [Fact] + public void Url_Works() + { + LicenseTypeCreateParams parameters = new() { GroupingKey = "x", Name = "x" }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True(TestBase.UrisEqual(new Uri("https://api.withorb.com/v1/license_types"), url)); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LicenseTypeCreateParams { GroupingKey = "x", Name = "x" }; + + 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..651ac9226 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeListParamsTest.cs @@ -0,0 +1,91 @@ +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.True( + TestBase.UrisEqual( + 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..dd1993b43 --- /dev/null +++ b/src/Orb.Tests/Models/LicenseTypes/LicenseTypeRetrieveParamsTest.cs @@ -0,0 +1,42 @@ +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.True( + TestBase.UrisEqual( + 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..8e4c769bb --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParamsTest.cs @@ -0,0 +1,180 @@ +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.True( + TestBase.UrisEqual( + 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..40a576b3b --- /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.True(TestBase.UrisEqual(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..f981581f5 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseDeactivateParamsTest.cs @@ -0,0 +1,75 @@ +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.True( + TestBase.UrisEqual( + 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..b2aa96d99 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseListParamsTest.cs @@ -0,0 +1,213 @@ +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.True( + TestBase.UrisEqual( + 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..4f3e88c84 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveByExternalIDParamsTest.cs @@ -0,0 +1,63 @@ +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.True( + TestBase.UrisEqual( + 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..ae827daf7 --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/LicenseRetrieveParamsTest.cs @@ -0,0 +1,39 @@ +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.True( + TestBase.UrisEqual(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..0e1871b3f --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetAllUsageParamsTest.cs @@ -0,0 +1,171 @@ +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.True( + TestBase.UrisEqual( + 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..331df513b --- /dev/null +++ b/src/Orb.Tests/Models/Licenses/Usage/UsageGetUsageParamsTest.cs @@ -0,0 +1,158 @@ +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.True( + TestBase.UrisEqual( + 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..405898dae 100644 --- a/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs @@ -84,6 +84,23 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/metrics"), url); + Assert.True(TestBase.UrisEqual(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..50a7a451f 100644 --- a/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs @@ -22,6 +22,18 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/metrics/metric_id"), url); + Assert.True( + TestBase.UrisEqual(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..9d3eb2318 100644 --- a/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs @@ -115,6 +115,31 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { MetricListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + Limit = 1, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/metrics?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" + ), + 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"), @@ -124,13 +149,8 @@ public void Url_Works() Limit = 1, }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + MetricListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/metrics?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs b/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs index 776ace1b8..d7ff511a6 100644 --- a/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs @@ -59,6 +59,22 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/metrics/metric_id"), url); + Assert.True( + TestBase.UrisEqual(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..bdcf7b546 100644 --- a/src/Orb.Tests/Models/NewAllocationPriceTest.cs +++ b/src/Orb.Tests/Models/NewAllocationPriceTest.cs @@ -32,6 +32,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; @@ -54,6 +56,8 @@ public void FieldRoundtrip_Works() }, ]; string expectedItemID = "item_id"; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; Assert.Equal(expectedAmount, model.Amount); @@ -68,6 +72,15 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFilters[i], model.Filters[i]); } Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + 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); } @@ -95,6 +108,8 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; @@ -131,6 +146,8 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; @@ -160,6 +177,8 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedItemID = "item_id"; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedPerUnitCostBasis = "per_unit_cost_basis"; Assert.Equal(expectedAmount, deserialized.Amount); @@ -174,6 +193,15 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFilters[i], deserialized.Filters[i]); } Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + 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); } @@ -201,6 +229,8 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; @@ -231,6 +261,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, }; Assert.Null(model.PerUnitCostBasis); @@ -261,6 +293,8 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, }; model.Validate(); @@ -290,6 +324,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, // Null should be interpreted as omitted for these properties PerUnitCostBasis = null, @@ -323,6 +359,8 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, // Null should be interpreted as omitted for these properties PerUnitCostBasis = null, @@ -350,6 +388,10 @@ 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")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); } [Fact] @@ -380,6 +422,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExpiresAtEndOfCadence = null, Filters = null, ItemID = null, + LicenseTypeID = null, + Metadata = null, }; Assert.Null(model.CustomExpiration); @@ -390,6 +434,10 @@ 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")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); } [Fact] @@ -406,10 +454,46 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExpiresAtEndOfCadence = null, Filters = null, ItemID = null, + LicenseTypeID = null, + Metadata = 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }; + + NewAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -566,6 +650,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..a1197a8b1 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() @@ -74,6 +75,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -121,6 +123,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 +177,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -189,6 +198,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -232,6 +242,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 +307,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -311,6 +328,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -358,6 +376,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 +444,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -440,6 +465,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -487,6 +513,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 +574,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -562,6 +595,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -605,6 +639,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 +704,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -684,6 +725,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -731,6 +773,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 +835,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -807,6 +856,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -854,6 +904,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 +966,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -930,6 +987,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -977,6 +1035,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 +1096,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1052,6 +1117,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1099,6 +1165,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 +1229,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1177,6 +1250,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1224,6 +1298,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 +1314,137 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..4edfa51d6 100644 --- a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs @@ -22,9 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/external_plan_id/external_plan_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/plans/external_plan_id/external_plan_id"), + 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..5080cef00 100644 --- a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs @@ -12,15 +12,18 @@ public void FieldRoundtrip_Works() var parameters = new ExternalPlanIDUpdateParams { OtherExternalPlanID = "external_plan_id", + Description = "description", ExternalPlanID = "external_plan_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedOtherExternalPlanID = "external_plan_id"; + string expectedDescription = "description"; string expectedExternalPlanID = "external_plan_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedOtherExternalPlanID, parameters.OtherExternalPlanID); + Assert.Equal(expectedDescription, parameters.Description); Assert.Equal(expectedExternalPlanID, parameters.ExternalPlanID); Assert.NotNull(parameters.Metadata); Assert.Equal(expectedMetadata.Count, parameters.Metadata.Count); @@ -40,6 +43,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() OtherExternalPlanID = "external_plan_id", }; + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.False(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -53,10 +58,13 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() { OtherExternalPlanID = "external_plan_id", + Description = null, ExternalPlanID = null, Metadata = null, }; + Assert.Null(parameters.Description); + Assert.True(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.True(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -70,9 +78,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/external_plan_id/external_plan_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/plans/external_plan_id/external_plan_id"), + url + ) ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDUpdateParams + { + OtherExternalPlanID = "external_plan_id", + Description = "description", + 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..8c2ece57b 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs @@ -32,9 +32,25 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/plan_id/migrations/migration_id/cancel"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/plans/plan_id/migrations/migration_id/cancel"), + 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..543c41137 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelResponseTest.cs @@ -14,13 +14,14 @@ public void FieldRoundtrip_Works() var model = new MigrationCancelResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationCancelResponseStatus.NotStarted, }; string expectedID = "id"; - MigrationCancelResponseEffectiveTime expectedEffectiveTime = "2019-12-27"; + MigrationCancelResponseEffectiveTime expectedEffectiveTime = + MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = MigrationCancelResponseStatus.NotStarted; @@ -37,7 +38,7 @@ public void SerializationRoundtrip_Works() var model = new MigrationCancelResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationCancelResponseStatus.NotStarted, }; @@ -57,7 +58,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new MigrationCancelResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationCancelResponseStatus.NotStarted, }; @@ -70,7 +71,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - MigrationCancelResponseEffectiveTime expectedEffectiveTime = "2019-12-27"; + MigrationCancelResponseEffectiveTime expectedEffectiveTime = + MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = MigrationCancelResponseStatus.NotStarted; @@ -87,13 +89,29 @@ public void Validation_Works() var model = new MigrationCancelResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationCancelResponseStatus.NotStarted, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationCancelResponse + { + ID = "id", + EffectiveTime = MigrationCancelResponseEffectiveTimeUnionMember2.EndOfTerm, + 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..0a3cfb464 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListPageResponseTest.cs @@ -18,7 +18,7 @@ public void FieldRoundtrip_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -31,7 +31,7 @@ public void FieldRoundtrip_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -60,7 +60,7 @@ public void SerializationRoundtrip_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -87,7 +87,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -107,7 +107,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -136,7 +136,7 @@ public void Validation_Works() new() { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }, @@ -146,4 +146,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationListPageResponse + { + Data = + [ + new() + { + ID = "id", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, + 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..616c88329 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs @@ -85,9 +85,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/plan_id/migrations?cursor=cursor&limit=1"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/plans/plan_id/migrations?cursor=cursor&limit=1" + ), + 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..bc851e34b 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListResponseTest.cs @@ -14,13 +14,14 @@ public void FieldRoundtrip_Works() var model = new MigrationListResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }; string expectedID = "id"; - MigrationListResponseEffectiveTime expectedEffectiveTime = "2019-12-27"; + MigrationListResponseEffectiveTime expectedEffectiveTime = + MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = MigrationListResponseStatus.NotStarted; @@ -37,7 +38,7 @@ public void SerializationRoundtrip_Works() var model = new MigrationListResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }; @@ -57,7 +58,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new MigrationListResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }; @@ -70,7 +71,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - MigrationListResponseEffectiveTime expectedEffectiveTime = "2019-12-27"; + MigrationListResponseEffectiveTime expectedEffectiveTime = + MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = MigrationListResponseStatus.NotStarted; @@ -87,13 +89,29 @@ public void Validation_Works() var model = new MigrationListResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, PlanID = "plan_id", Status = MigrationListResponseStatus.NotStarted, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationListResponse + { + ID = "id", + EffectiveTime = MigrationListResponseEffectiveTimeUnionMember2.EndOfTerm, + 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..6254b032f 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs @@ -32,9 +32,25 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/plans/plan_id/migrations/migration_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/plans/plan_id/migrations/migration_id"), + 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..e3a4bc250 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveResponseTest.cs @@ -14,13 +14,13 @@ public void FieldRoundtrip_Works() var model = new MigrationRetrieveResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = UnionMember2.EndOfTerm, PlanID = "plan_id", Status = Status.NotStarted, }; string expectedID = "id"; - EffectiveTime expectedEffectiveTime = "2019-12-27"; + EffectiveTime expectedEffectiveTime = UnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = Status.NotStarted; @@ -36,7 +36,7 @@ public void SerializationRoundtrip_Works() var model = new MigrationRetrieveResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = UnionMember2.EndOfTerm, PlanID = "plan_id", Status = Status.NotStarted, }; @@ -56,7 +56,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new MigrationRetrieveResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = UnionMember2.EndOfTerm, PlanID = "plan_id", Status = Status.NotStarted, }; @@ -69,7 +69,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedID = "id"; - EffectiveTime expectedEffectiveTime = "2019-12-27"; + EffectiveTime expectedEffectiveTime = UnionMember2.EndOfTerm; string expectedPlanID = "plan_id"; ApiEnum expectedStatus = Status.NotStarted; @@ -85,13 +85,29 @@ public void Validation_Works() var model = new MigrationRetrieveResponse { ID = "id", - EffectiveTime = "2019-12-27", + EffectiveTime = UnionMember2.EndOfTerm, PlanID = "plan_id", Status = Status.NotStarted, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MigrationRetrieveResponse + { + ID = "id", + EffectiveTime = UnionMember2.EndOfTerm, + 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..df740a5a7 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -42,8 +42,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -81,6 +132,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -115,6 +167,7 @@ public void FieldRoundtrip_Works() }, ], DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", ExternalPlanID = "external_plan_id", Metadata = new Dictionary() { { "foo", "string" } }, NetTerms = 0, @@ -158,8 +211,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -197,6 +301,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -230,6 +335,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedDefaultInvoiceMemo = "default_invoice_memo"; + string expectedDescription = "description"; string expectedExternalPlanID = "external_plan_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; long expectedNetTerms = 0; @@ -259,6 +365,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedAdjustments[i], parameters.Adjustments[i]); } Assert.Equal(expectedDefaultInvoiceMemo, parameters.DefaultInvoiceMemo); + Assert.Equal(expectedDescription, parameters.Description); Assert.Equal(expectedExternalPlanID, parameters.ExternalPlanID); Assert.NotNull(parameters.Metadata); Assert.Equal(expectedMetadata.Count, parameters.Metadata.Count); @@ -310,8 +417,59 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -349,6 +507,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -383,6 +542,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", ExternalPlanID = "external_plan_id", Metadata = new Dictionary() { { "foo", "string" } }, NetTerms = 0, @@ -434,8 +594,59 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -473,6 +684,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -507,6 +719,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], DefaultInvoiceMemo = "default_invoice_memo", + Description = "description", ExternalPlanID = "external_plan_id", Metadata = new Dictionary() { { "foo", "string" } }, NetTerms = 0, @@ -561,8 +774,59 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -600,6 +864,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -612,6 +877,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawBodyData.ContainsKey("adjustments")); Assert.Null(parameters.DefaultInvoiceMemo); Assert.False(parameters.RawBodyData.ContainsKey("default_invoice_memo")); + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.False(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -654,8 +921,59 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -693,6 +1011,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -702,6 +1021,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Adjustments = null, DefaultInvoiceMemo = null, + Description = null, ExternalPlanID = null, Metadata = null, NetTerms = null, @@ -712,6 +1032,8 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Assert.True(parameters.RawBodyData.ContainsKey("adjustments")); Assert.Null(parameters.DefaultInvoiceMemo); Assert.True(parameters.RawBodyData.ContainsKey("default_invoice_memo")); + Assert.Null(parameters.Description); + Assert.True(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.True(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -754,12 +1076,63 @@ public void Url_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - PriceValue = new Models::NewPlanUnitPrice() + LicenseAllocationPrice = new() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + PlanPhaseOrder = 0, + PriceValue = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", @@ -793,6 +1166,7 @@ public void Url_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -802,7 +1176,186 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans"), url); + Assert.True(TestBase.UrisEqual(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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, + 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", + Description = "description", + 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); } } @@ -834,8 +1387,59 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -873,6 +1477,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -899,12 +1504,62 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; - long expectedPlanPhaseOrder = 0; - PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() + LicenseAllocationPrice expectedLicenseAllocationPrice = new() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; + long expectedPlanPhaseOrder = 0; + PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", @@ -937,11 +1592,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 +1629,59 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1011,6 +1719,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 +1757,59 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1087,6 +1847,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 +1878,58 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; + LicenseAllocationPrice expectedLicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }; long expectedPlanPhaseOrder = 0; PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() { @@ -1155,11 +1966,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 +2003,59 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new Models::NewPlanUnitPrice() { @@ -1229,6 +2093,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 +2109,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 +2131,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,82 +2152,163 @@ 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + LicenseAllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.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", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + PlanPhaseOrder = 0, + PriceValue = new Models::NewPlanUnitPrice() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + Price copied = new(model); + + Assert.Equal(model, copied); } +} +public class LicenseAllocationPriceTest : TestBase +{ [Fact] - public void NewPlanTieredValidationWorks() + public void FieldRoundtrip_Works() { - PricePrice value = new Models::NewPlanTieredPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1386,22 +2337,114 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedLicenseAllocations.Count, model.LicenseAllocations.Count); + for (int i = 0; i < expectedLicenseAllocations.Count; i++) + { + Assert.Equal(expectedLicenseAllocations[i], model.LicenseAllocations[i]); + } + Assert.Equal(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 NewPlanBulkValidationWorks() + public void SerializationRoundtrip_Works() { - PricePrice value = new Models::NewPlanBulkPrice() + var model = new LicenseAllocationPrice { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1430,29 +2473,39 @@ public void NewPlanBulkValidationWorks() 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 BulkWithFiltersValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - PricePrice value = new BulkWithFilters() + var model = new LicenseAllocationPrice { - BulkWithFiltersConfig = new() - { - 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, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1481,71 +2534,124 @@ public void BulkWithFiltersValidationWorks() 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, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = Cadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + ApiEnum expectedModelType = ModelType.Unit; + string expectedName = "Annual fee"; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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(expectedItemID, deserialized.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(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 NewPlanMatrixValidationWorks() + public void Validation_Works() { - PricePrice value = new Models::NewPlanMatrixPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1574,260 +2680,213 @@ public void NewPlanMatrixValidationWorks() 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 NewPlanThresholdTotalAmountValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - PricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; - 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 NewPlanTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - PricePrice value = new Models::NewPlanTieredPackagePrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - PricePrice value = new Models::NewPlanTieredWithMinimumPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - 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 NewPlanGroupedTieredValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - PricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new LicenseAllocationPrice { - 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" }, - ], - }, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void CopyConstructor_Works() { - PricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new LicenseAllocationPrice { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = ModelType.Unit, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1856,259 +2915,369 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + + LicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CadenceTest : TestBase +{ + [Theory] + [InlineData(Cadence.Annual)] + [InlineData(Cadence.SemiAnnual)] + [InlineData(Cadence.Monthly)] + [InlineData(Cadence.Quarterly)] + [InlineData(Cadence.OneTime)] + [InlineData(Cadence.Custom)] + public void Validation_Works(Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void InvalidEnumValidationThrows_Works() { - 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, - }, - 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(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 NewPlanUnitWithPercentValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - PricePrice value = new Models::NewPlanUnitWithPercentPrice() + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class LicenseAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new LicenseAllocation { - 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"), - }, + 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 NewPlanMatrixWithAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - PricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new LicenseAllocation { - 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"), - }, + 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 TieredWithProrationValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - PricePrice value = new TieredWithProration() + var model = new LicenseAllocation { - Cadence = TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + 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 NewPlanUnitWithProrationValidationWorks() + public void Validation_Works() { - PricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new LicenseAllocation { - 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"), - }, + 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 NewPlanGroupedAllocationValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - PricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new LicenseAllocation { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; + + LicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ModelTypeTest : TestBase +{ + [Theory] + [InlineData(ModelType.Unit)] + public void Validation_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(ModelType.Unit)] + public void SerializationRoundtrip_Works(ModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PricePriceTest : TestBase +{ + [Fact] + public void NewPlanUnitValidationWorks() + { + PricePrice value = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2137,6 +3306,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2144,20 +3314,27 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void NewPlanTieredValidationWorks() { - PricePrice value = new Models::NewPlanBulkWithProrationPrice() + PricePrice value = new Models::NewPlanTieredPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -2186,6 +3363,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2193,20 +3371,14 @@ public void NewPlanBulkWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void NewPlanBulkValidationWorks() { - PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + PricePrice value = new Models::NewPlanBulkPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2236,6 +3408,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2243,29 +3416,21 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void BulkWithFiltersValidationWorks() { - PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + PricePrice value = new BulkWithFilters() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2295,6 +3460,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2302,20 +3468,15 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void NewPlanPackageValidationWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + PricePrice value = new Models::NewPlanPackagePrice() { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -2344,6 +3505,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2351,26 +3513,19 @@ public void GroupedWithMinMaxThresholdsValidationWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void NewPlanMatrixValidationWorks() { - PricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + PricePrice value = new Models::NewPlanMatrixPrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Models::NewPlanMatrixPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + MatrixConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2400,6 +3555,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2407,24 +3563,23 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void NewPlanThresholdTotalAmountValidationWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + PricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + ConsumptionTable = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], + Prorate = true, }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2453,6 +3608,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2460,24 +3616,23 @@ public void NewPlanGroupedTieredPackageValidationWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void NewPlanTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + PricePrice value = new Models::NewPlanTieredPackagePrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() { - GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2506,6 +3661,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2513,30 +3669,33 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void NewPlanTieredWithMinimumValidationWorks() { - PricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + PricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + TieredWithMinimumConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - UnitPrice = "unit_price", + HideZeroAmountTiers = true, Prorate = true, - SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2566,6 +3725,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2573,34 +3733,23 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void NewPlanGroupedTieredValidationWorks() { - PricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + PricePrice value = new Models::NewPlanGroupedTieredPrice() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], + GroupingKey = "x", Tiers = [ new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - SecondDimension = "second_dimension", }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2629,6 +3778,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2636,27 +3786,34 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + PricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - DimensionValues = + PackageSize = 0, + Tiers = [ new() { - GroupingKey = "x", + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", 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() @@ -2685,6 +3842,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2692,20 +3850,20 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewPlanPackageWithAllocationValidationWorks() { - PricePrice value = new CumulativeGroupedAllocation() + PricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -2734,6 +3892,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2741,14 +3900,15 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewPlanUnitWithPercentValidationWorks() { - PricePrice value = new Minimum() + PricePrice value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = MinimumCadence.Annual, + Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2777,6 +3937,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2784,14 +3945,20 @@ public void MinimumValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void NewPlanMatrixWithAllocationValidationWorks() { - PricePrice value = new Models::NewPlanMinimumCompositePrice() + PricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + 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, @@ -2821,6 +3988,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2828,14 +3996,39 @@ public void NewPlanMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void MatrixWithThresholdDiscountsValidationWorks() { - PricePrice value = new Percent() + PricePrice value = new MatrixWithThresholdDiscounts() { - Cadence = PercentCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2864,6 +4057,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2871,19 +4065,16 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void TieredWithProrationValidationWorks() { - PricePrice value = new EventOutput() + PricePrice value = new TieredWithProration() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2912,6 +4103,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2919,15 +4111,15 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void NewPlanUnitWithProrationValidationWorks() { - PricePrice value = new Models::NewPlanUnitPrice() + PricePrice value = new Models::NewPlanUnitWithProrationPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2956,43 +4148,31 @@ 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); + value.Validate(); } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void NewPlanGroupedAllocationValidationWorks() { - PricePrice value = new Models::NewPlanTieredPrice() + PricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, @@ -3018,27 +4198,27 @@ 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void NewPlanBulkWithProrationValidationWorks() { - PricePrice value = new Models::NewPlanBulkPrice() + PricePrice value = new Models::NewPlanBulkWithProrationPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + 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::NewPlanBulkPriceModelType.Bulk, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3068,34 +4248,28 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - PricePrice value = new BulkWithFilters() + PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - Cadence = Cadence.Annual, ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3125,28 +4299,38 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void NewPlanGroupedWithMeteredMinimumValidationWorks() { - PricePrice value = new Models::NewPlanPackagePrice() + PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + 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::NewPlanPackagePriceModelType.Package, + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3175,32 +4359,27 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { - PricePrice value = new Models::NewPlanMatrixPrice() + PricePrice value = new GroupedWithMinMaxThresholds() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - 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 = Models::NewPlanMatrixPriceModelType.Matrix, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3230,36 +4409,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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - PricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + PricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MatrixWithDisplayNameConfig = new() { - ConsumptionTable = + Dimension = "dimension", + UnitAmounts = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], - Prorate = true, }, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3288,29 +4466,22 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void NewPlanGroupedTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanTieredPackagePrice() + PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { + GroupingKey = "x", PackageSize = "package_size", Tiers = [ @@ -3318,6 +4489,9 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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() @@ -3346,47 +4520,32 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanTieredWithMinimumPrice() + PricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + MaxGroupTieredPackageConfig = new() { + GroupingKey = "x", + 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", - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - HideZeroAmountTiers = true, - Prorate = true, }, + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3415,36 +4574,40 @@ 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); + value.Validate(); } [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPrice() + PricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() { - GroupingKey = "x", - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3473,46 +4636,41 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - PricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + PricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - PackageSize = 0, - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + 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, @@ -3542,33 +4700,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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - PricePrice value = new Models::NewPlanPackageWithAllocationPrice() + PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -3597,28 +4757,28 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { - PricePrice value = new Models::NewPlanUnitWithPercentPrice() + PricePrice value = new CumulativeGroupedAllocation() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, 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() @@ -3647,33 +4807,28 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void DailyCreditAllowanceValidationWorks() { - PricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + PricePrice value = new DailyCreditAllowance() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Allocation = "allocation", + DailyAllowance = "daily_allowance", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], + EventDayProperty = "x", MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3703,29 +4858,30 @@ 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); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void MeteredAllowanceValidationWorks() { - PricePrice value = new TieredWithProration() + PricePrice value = new MeteredAllowance() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3754,28 +4910,23 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void NewPlanMinimumCompositeValidationWorks() { - PricePrice value = new Models::NewPlanUnitWithProrationPrice() + PricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3804,33 +4955,22 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void PercentValidationWorks() { - PricePrice value = new Models::NewPlanGroupedAllocationPrice() + PricePrice value = new Percent() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3859,32 +4999,26 @@ 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 - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - PricePrice value = new Models::NewPlanBulkWithProrationPrice() + PricePrice value = new EventOutput() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3914,34 +5048,23 @@ 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); + value.Validate(); } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + PricePrice value = new Models::NewPlanUnitPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + ModelType = Models::NewPlanUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3970,6 +5093,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3983,30 +5107,27 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewPlanTieredSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + PricePrice value = new Models::NewPlanTieredPrice() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + Tiers = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4035,727 +5156,4720 @@ 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 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + PricePrice value = new MatrixWithThresholdDiscounts() + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 TieredWithProration() + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 GroupedWithMinMaxThresholds() + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 CumulativeGroupedAllocation() + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DailyCreditAllowanceSerializationRoundtripWorks() + { + PricePrice value = new DailyCreditAllowance() + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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 MeteredAllowanceSerializationRoundtripWorks() + { + PricePrice value = new MeteredAllowance() + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 Percent() + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 EventOutput() + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string json = 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = 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"; + 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.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + 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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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 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 MatrixWithThresholdDiscountsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force 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(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class MatrixWithThresholdDiscountsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + MatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + 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() { - PricePrice value = new GroupedWithMinMaxThresholds() + var model = new MatrixValue { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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); + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void Validation_Works() { - PricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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() { - PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - PricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new MatrixValue { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdDiscountGroupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - PricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new ThresholdDiscountGroup { - 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - PricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new ThresholdDiscountGroup { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - 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); + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new ThresholdDiscountGroup { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - PricePrice value = new CumulativeGroupedAllocation() + var model = new ThresholdDiscountGroup { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - PricePrice value = new Minimum() + var model = new ThresholdDiscountGroup { - 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", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - PricePrice value = new Models::NewPlanMinimumCompositePrice() + var model = new ThresholdDiscountGroup { - 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", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void CopyConstructor_Works() { - PricePrice value = new Percent() + var model = new ThresholdDiscountGroup { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ThresholdDiscountGroup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - PricePrice value = new EventOutput() - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MatrixWithThresholdDiscountsConversionRateConfig 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class BulkWithFiltersTest : TestBase +public class TieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4784,23 +9898,19 @@ 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; + ApiEnum expectedCadence = + TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -4809,7 +9919,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + TieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -4830,14 +9940,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); @@ -4849,6 +9960,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9975,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4905,12 +10011,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 ); @@ -4921,20 +10028,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4963,30 +10064,26 @@ 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); - 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; + ApiEnum expectedCadence = + TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -4995,7 +10092,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + TieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5016,14 +10113,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); @@ -5038,6 +10136,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10151,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5094,6 +10187,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 +10198,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -5142,6 +10230,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10241,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -5173,20 +10257,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -5199,6 +10277,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5225,6 +10304,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10315,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new TieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Cadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -5260,41 +10335,145 @@ 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 TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 BulkWithFiltersConfigTest : TestBase +public class TieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new TieredWithProrationConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + List expectedTiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; - 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++) { @@ -5305,18 +10484,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFiltersConfig + var model = new TieredWithProrationConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5327,35 +10501,23 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFiltersConfig + var model = new TieredWithProrationConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = + List expectedTiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; - 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++) { @@ -5366,91 +10528,60 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFiltersConfig + var model = new TieredWithProrationConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } -} - -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() + public void CopyConstructor_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); - } + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - [Fact] - public void Validation_Works() - { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + TieredWithProrationConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class TierTest : TestBase +public class TieredWithProrationConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - string expectedUnitAmount = "unit_amount"; string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedUnitAmount, model.UnitAmount); Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -5458,144 +10589,59 @@ public void SerializationRoundtrip_Works() [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 + var model = new TieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", 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, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + 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 ConversionRateConfigTest : TestBase +public class TieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -5606,33 +10652,34 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + TieredWithProrationConversionRateConfig 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 ); @@ -5643,22 +10690,23 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5667,19 +10715,23 @@ public void TieredSerializationRoundtripWorks() } } -public class TieredWithProrationTest : TestBase +public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5708,18 +10760,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 = - TieredWithProrationCadence.Annual; + 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("tiered_with_proration"); - string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + 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() @@ -5728,7 +10787,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5749,14 +10808,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( + 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); @@ -5768,6 +10831,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10846,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5818,12 +10886,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 ); @@ -5834,14 +10903,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5870,25 +10943,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 = - TieredWithProrationCadence.Annual; + 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("tiered_with_proration"); - string expectedName = "Annual fee"; - TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + 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() @@ -5897,7 +10977,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5918,14 +10998,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( + 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); @@ -5940,6 +11024,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11039,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5990,6 +11079,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 +11090,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -6032,6 +11126,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11137,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -6057,14 +11157,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6077,6 +11181,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6103,6 +11208,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11219,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new GroupedWithMinMaxThresholds { - Cadence = TieredWithProrationCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -6132,34 +11243,88 @@ 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 GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationCadenceTest : TestBase +public class GroupedWithMinMaxThresholdsCadenceTest : 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(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; + 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,22 +11334,21 @@ 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(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; + 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); } @@ -6192,52 +11356,56 @@ 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>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class TieredWithProrationConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new GroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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 TieredWithProrationConfig + var model = new GroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6248,131 +11416,81 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new GroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; 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 expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + 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 TieredWithProrationConfig + var model = new GroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } -} - -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() + public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new GroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - model.Validate(); + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - TieredWithProrationConversionRateConfig value = + GroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6393,16 +11511,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + 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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -6410,7 +11530,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + GroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6426,29 +11546,30 @@ 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 CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6480,22 +11601,23 @@ 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() + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6506,7 +11628,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6527,13 +11649,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -6549,6 +11672,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,15 +11687,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6603,12 +11727,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,15 +11744,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6659,29 +11784,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6692,7 +11818,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6713,13 +11839,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -6738,6 +11865,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,15 +11880,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6792,6 +11920,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6802,15 +11931,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6838,6 +11967,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +11978,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6867,15 +11998,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", @@ -6891,6 +12022,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6917,6 +12049,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,58 +12060,112 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.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", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - 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, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - model.Validate(); + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : 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(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; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -6987,20 +12175,20 @@ 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(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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -7009,56 +12197,56 @@ 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 + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class GroupedWithMinMaxThresholdsConfigTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7069,53 +12257,69 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7127,7 +12331,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7148,7 +12352,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7156,7 +12360,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7167,7 +12371,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7184,7 +12388,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7193,20 +12397,21 @@ public void TieredSerializationRoundtripWorks() } } -public class CumulativeGroupedAllocationTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7238,23 +12443,23 @@ 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() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7264,7 +12469,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7285,14 +12490,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -7307,6 +12510,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12525,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7361,12 +12566,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 +12583,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7417,30 +12624,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7450,7 +12657,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7471,14 +12678,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -7496,6 +12701,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12716,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7550,6 +12757,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 +12768,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7596,6 +12805,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12816,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7625,15 +12837,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7649,6 +12862,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7675,6 +12889,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12900,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -7708,34 +12925,89 @@ 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 DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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", + }; + + DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : 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(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(DailyCreditAllowanceCadence 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 ); @@ -7745,21 +13017,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCadence 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); } @@ -7767,56 +13040,188 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7827,53 +13232,63 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7885,7 +13300,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7906,18 +13321,17 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new 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); } @@ -7925,7 +13339,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7941,26 +13355,33 @@ 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 MinimumTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7990,18 +13411,23 @@ 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 = MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8011,7 +13437,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8032,12 +13458,13 @@ 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(expectedMinimumConfig, model.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -8051,6 +13478,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +13493,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8099,12 +13535,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 +13552,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8146,25 +13594,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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8174,7 +13627,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8195,12 +13648,13 @@ 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(expectedMinimumConfig, deserialized.MinimumConfig); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -8217,6 +13671,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +13686,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8265,6 +13728,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 +13739,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -8305,6 +13777,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +13788,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -8328,11 +13810,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -8346,6 +13836,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8372,6 +13863,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +13874,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -8399,34 +13900,90 @@ 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 MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void Validation_Works(MeteredAllowanceCadence 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 ); @@ -8436,19 +13993,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(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(MeteredAllowanceCadence 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 ); @@ -8459,12 +14016,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 ); @@ -8473,27 +14030,51 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8504,26 +14085,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; model.Validate(); } @@ -8531,16 +14136,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -8548,39 +14167,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -8591,7 +14238,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8611,13 +14258,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig 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 ); @@ -8628,7 +14275,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8643,7 +14290,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8691,6 +14338,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8729,6 +14377,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 +14397,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8796,6 +14446,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8843,6 +14494,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8888,6 +14540,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 +14563,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8958,6 +14612,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8998,6 +14653,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9039,6 +14696,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9065,6 +14723,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9092,12 +14752,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 Percent + { + Cadence = PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentCadenceTest : TestBase @@ -9216,6 +14924,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -9339,6 +15057,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9382,6 +15101,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 +15121,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -9454,6 +15175,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9509,6 +15231,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9559,6 +15282,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 +15305,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9634,6 +15359,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9679,6 +15405,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9730,6 +15458,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9756,6 +15485,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9788,12 +15519,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 EventOutput + { + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -9990,6 +15774,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 @@ -10379,6 +16178,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 +16650,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..845a91c93 100644 --- a/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs @@ -22,6 +22,16 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id"), url); + Assert.True(TestBase.UrisEqual(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..1d551d0a5 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() @@ -235,6 +236,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -282,6 +284,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 +504,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -516,6 +525,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -563,6 +573,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 +811,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -816,6 +833,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -863,6 +881,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 +1117,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1114,6 +1139,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1161,6 +1187,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 +1414,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1402,6 +1435,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1449,6 +1483,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 +1721,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1702,6 +1743,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1749,6 +1791,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 +1815,306 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..264f53668 100644 --- a/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs @@ -127,6 +127,32 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { PlanListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + Limit = 1, + Status = PlanListParamsStatus.Active, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/plans?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1&status=active" + ), + 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"), @@ -137,14 +163,9 @@ public void Url_Works() Status = PlanListParamsStatus.Active, }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + PlanListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/plans?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&limit=1&status=active" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Plans/PlanTest.cs b/src/Orb.Tests/Models/Plans/PlanTest.cs index ff7d72d34..b559e5de6 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() @@ -229,6 +230,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -276,6 +278,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 +490,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -502,6 +511,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -549,6 +559,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 +825,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -829,6 +846,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -876,6 +894,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 +1118,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1114,6 +1139,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1161,6 +1187,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 +1403,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1391,6 +1424,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1438,6 +1472,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 +1738,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1718,6 +1759,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1765,6 +1807,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 +1828,298 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +2494,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 +2901,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 +3106,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 +3237,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..d62334ab4 100644 --- a/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs @@ -12,15 +12,18 @@ public void FieldRoundtrip_Works() var parameters = new PlanUpdateParams { PlanID = "plan_id", + Description = "description", ExternalPlanID = "external_plan_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPlanID = "plan_id"; + string expectedDescription = "description"; string expectedExternalPlanID = "external_plan_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedPlanID, parameters.PlanID); + Assert.Equal(expectedDescription, parameters.Description); Assert.Equal(expectedExternalPlanID, parameters.ExternalPlanID); Assert.NotNull(parameters.Metadata); Assert.Equal(expectedMetadata.Count, parameters.Metadata.Count); @@ -37,6 +40,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() { var parameters = new PlanUpdateParams { PlanID = "plan_id" }; + Assert.Null(parameters.Description); + Assert.False(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.False(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -50,10 +55,13 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() { PlanID = "plan_id", + Description = null, ExternalPlanID = null, Metadata = null, }; + Assert.Null(parameters.Description); + Assert.True(parameters.RawBodyData.ContainsKey("description")); Assert.Null(parameters.ExternalPlanID); Assert.True(parameters.RawBodyData.ContainsKey("external_plan_id")); Assert.Null(parameters.Metadata); @@ -67,6 +75,22 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id"), url); + Assert.True(TestBase.UrisEqual(new Uri("https://api.withorb.com/v1/plans/plan_id"), url)); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PlanUpdateParams + { + PlanID = "plan_id", + Description = "description", + 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..2d6d3f422 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() @@ -90,6 +91,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -137,9 +139,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 +215,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -223,6 +236,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -266,9 +280,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 +321,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 +393,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -381,6 +414,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -428,9 +462,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 +548,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -524,6 +569,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -571,9 +617,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 +700,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -664,6 +721,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -707,9 +765,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 +809,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 +886,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -825,6 +907,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -872,11 +955,758 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..19ae3ab0d 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() @@ -73,6 +74,7 @@ public void UnitValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -116,6 +118,12 @@ public void UnitValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -164,6 +172,7 @@ public void TieredValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -184,6 +193,7 @@ public void TieredValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -239,6 +249,12 @@ public void TieredValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -288,6 +304,7 @@ public void BulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -308,6 +325,7 @@ public void BulkValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -350,6 +368,12 @@ public void BulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -407,6 +431,7 @@ public void BulkWithFiltersValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -427,6 +452,7 @@ public void BulkWithFiltersValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -469,6 +495,12 @@ public void BulkWithFiltersValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -517,6 +549,7 @@ public void PackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -537,6 +570,7 @@ public void PackageValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -580,6 +614,12 @@ public void PackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -628,6 +668,7 @@ public void MatrixValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -648,6 +689,7 @@ public void MatrixValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -696,6 +738,12 @@ public void MatrixValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -744,6 +792,7 @@ public void ThresholdTotalAmountValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -764,6 +813,7 @@ public void ThresholdTotalAmountValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -815,6 +865,12 @@ public void ThresholdTotalAmountValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -863,6 +919,7 @@ public void TieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -883,6 +940,7 @@ public void TieredPackageValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -934,6 +992,12 @@ public void TieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -982,6 +1046,7 @@ public void TieredWithMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1002,6 +1067,7 @@ public void TieredWithMinimumValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1064,6 +1130,12 @@ public void TieredWithMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1112,6 +1184,7 @@ public void GroupedTieredValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1141,6 +1214,7 @@ public void GroupedTieredValidationWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1183,6 +1257,12 @@ public void GroupedTieredValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1231,6 +1311,7 @@ public void TieredPackageWithMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1251,6 +1332,7 @@ public void TieredPackageWithMinimumValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1312,6 +1394,12 @@ public void TieredPackageWithMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1360,6 +1448,7 @@ public void PackageWithAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1380,6 +1469,7 @@ public void PackageWithAllocationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1428,6 +1518,12 @@ public void PackageWithAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1476,6 +1572,7 @@ public void UnitWithPercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1496,6 +1593,7 @@ public void UnitWithPercentValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1539,6 +1637,12 @@ public void UnitWithPercentValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1587,6 +1691,7 @@ public void MatrixWithAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1607,6 +1712,7 @@ public void MatrixWithAllocationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -1656,6 +1762,156 @@ public void MatrixWithAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Price value = new MatrixWithThresholdDiscounts() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.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, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Maximum = new() + { + AppliesToPriceIds = ["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 = MatrixWithThresholdDiscountsPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1704,6 +1960,7 @@ public void TieredWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1724,6 +1981,7 @@ public void TieredWithProrationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1769,6 +2027,12 @@ public void TieredWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1817,6 +2081,7 @@ public void UnitWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1837,6 +2102,7 @@ public void UnitWithProrationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1880,6 +2146,12 @@ public void UnitWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1928,6 +2200,7 @@ public void GroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1954,6 +2227,7 @@ public void GroupedAllocationValidationWorks() GroupingKey = "x", OverageUnitRate = "overage_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -1996,6 +2270,12 @@ public void GroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2050,6 +2330,7 @@ public void BulkWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2070,6 +2351,7 @@ public void BulkWithProrationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2112,6 +2394,12 @@ public void BulkWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2160,6 +2448,7 @@ public void GroupedWithProratedMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2186,6 +2475,7 @@ public void GroupedWithProratedMinimumValidationWorks() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2228,6 +2518,12 @@ public void GroupedWithProratedMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2276,6 +2572,7 @@ public void GroupedWithMeteredMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2311,6 +2608,7 @@ public void GroupedWithMeteredMinimumValidationWorks() new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2353,6 +2651,12 @@ public void GroupedWithMeteredMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2401,6 +2705,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2428,6 +2733,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() MinimumCharge = "minimum_charge", PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2470,6 +2776,12 @@ public void GroupedWithMinMaxThresholdsValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2518,6 +2830,7 @@ public void MatrixWithDisplayNameValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2538,6 +2851,7 @@ public void MatrixWithDisplayNameValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithDisplayNameConfig = new() @@ -2593,6 +2907,12 @@ public void MatrixWithDisplayNameValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2641,6 +2961,7 @@ public void GroupedTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2671,6 +2992,7 @@ public void GroupedTieredPackageValidationWorks() new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2713,6 +3035,12 @@ public void GroupedTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2761,6 +3089,7 @@ public void MaxGroupTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2781,6 +3110,7 @@ public void MaxGroupTieredPackageValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MaxGroupTieredPackageConfig = new() @@ -2833,6 +3163,12 @@ public void MaxGroupTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2881,6 +3217,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2901,6 +3238,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -2951,6 +3289,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2959,6 +3298,12 @@ public void ScalableMatrixWithUnitPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3007,6 +3352,7 @@ public void ScalableMatrixWithTieredPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3027,6 +3373,7 @@ public void ScalableMatrixWithTieredPricingValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3088,6 +3435,12 @@ public void ScalableMatrixWithTieredPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3136,6 +3489,7 @@ public void CumulativeGroupedBulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -3169,6 +3523,7 @@ public void CumulativeGroupedBulkValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3211,6 +3566,12 @@ public void CumulativeGroupedBulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3259,6 +3620,7 @@ public void CumulativeGroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -3286,6 +3648,7 @@ public void CumulativeGroupedAllocationValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3328,26 +3691,32 @@ public void CumulativeGroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - Price value = new PriceMinimum() + Price value = new DailyCreditAllowance() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3376,8 +3745,17 @@ public void MinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -3396,6 +3774,7 @@ public void MinimumValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3429,36 +3808,41 @@ public void MinimumValidationWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } [Fact] - public void MinimumCompositeValidationWorks() + public void MeteredAllowanceValidationWorks() { - Price value = new MinimumComposite() + Price value = new MeteredAllowance() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MinimumCompositeBillingMode.InAdvance, - Cadence = MinimumCompositeCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3487,6 +3871,7 @@ public void MinimumCompositeValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3507,6 +3892,7 @@ public void MinimumCompositeValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3525,6 +3911,15 @@ public void MinimumCompositeValidationWorks() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -3540,36 +3935,41 @@ public void MinimumCompositeValidationWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = MinimumCompositePriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } [Fact] - public void PercentValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new Percent() + Price value = new MinimumComposite() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PercentBillingMode.InAdvance, - Cadence = PercentCadence.OneTime, + BillingMode = MinimumCompositeBillingMode.InAdvance, + Cadence = MinimumCompositeCadence.OneTime, CompositePriceFilters = [ new() { - Field = PercentCompositePriceFilterField.PriceID, - Operator = PercentCompositePriceFilterOperator.Includes, + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3598,6 +3998,7 @@ public void PercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3618,6 +4019,7 @@ public void PercentValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3651,36 +4053,42 @@ public void PercentValidationWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", - PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = PercentPriceType.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", + }, }; value.Validate(); } [Fact] - public void EventOutputValidationWorks() + public void PercentValidationWorks() { - Price value = new EventOutput() + Price value = new Percent() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = EventOutputBillingMode.InAdvance, - Cadence = EventOutputCadence.OneTime, + BillingMode = PercentBillingMode.InAdvance, + Cadence = PercentCadence.OneTime, CompositePriceFilters = [ new() { - Field = EventOutputCompositePriceFilterField.PriceID, - Operator = EventOutputCompositePriceFilterOperator.Includes, + Field = PercentCompositePriceFilterField.PriceID, + Operator = PercentCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3709,6 +4117,126 @@ public void EventOutputValidationWorks() 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + Price value = new EventOutput() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = EventOutputBillingMode.InAdvance, + Cadence = EventOutputCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, + 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() @@ -3735,6 +4263,7 @@ public void EventOutputValidationWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3777,6 +4306,12 @@ public void EventOutputValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3825,6 +4360,7 @@ public void UnitSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3845,6 +4381,7 @@ public void UnitSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -3888,6 +4425,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 +4482,7 @@ public void TieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3959,6 +4503,7 @@ public void TieredSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4014,6 +4559,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 +4617,7 @@ public void BulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4086,6 +4638,7 @@ public void BulkSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4128,6 +4681,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 +4747,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4208,6 +4768,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4250,6 +4811,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 +4868,7 @@ public void PackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4321,6 +4889,7 @@ public void PackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4364,6 +4933,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 +4990,7 @@ public void MatrixSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4435,6 +5011,7 @@ public void MatrixSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -4483,6 +5060,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 +5117,7 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4554,6 +5138,7 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4605,6 +5190,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 +5247,7 @@ public void TieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4676,6 +5268,7 @@ public void TieredPackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4727,6 +5320,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 +5377,7 @@ public void TieredWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4798,6 +5398,7 @@ public void TieredWithMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4860,6 +5461,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 +5518,7 @@ public void GroupedTieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4940,6 +5548,7 @@ public void GroupedTieredSerializationRoundtripWorks() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4982,6 +5591,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 +5648,7 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5053,6 +5669,7 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5114,6 +5731,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 +5788,7 @@ public void PackageWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5185,6 +5809,7 @@ public void PackageWithAllocationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5233,6 +5858,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 +5915,7 @@ public void UnitWithPercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5304,6 +5936,7 @@ public void UnitWithPercentSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5347,6 +5980,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 +6037,7 @@ public void MatrixWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5418,6 +6058,7 @@ public void MatrixWithAllocationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -5467,6 +6108,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); @@ -5475,21 +6122,21 @@ public void MatrixWithAllocationSerializationRoundtripWorks() } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - Price value = new TieredWithProration() + Price value = new MatrixWithThresholdDiscounts() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5518,6 +6165,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5538,8 +6186,35 @@ public void TieredWithProrationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -5573,16 +6248,19 @@ public void TieredWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5591,21 +6269,21 @@ public void TieredWithProrationSerializationRoundtripWorks() } [Fact] - public void UnitWithProrationSerializationRoundtripWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - Price value = new UnitWithProration() + Price value = new TieredWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5634,6 +6312,7 @@ public void UnitWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5654,6 +6333,7 @@ public void UnitWithProrationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5689,14 +6369,22 @@ public void UnitWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5705,21 +6393,21 @@ public void UnitWithProrationSerializationRoundtripWorks() } [Fact] - public void GroupedAllocationSerializationRoundtripWorks() + public void UnitWithProrationSerializationRoundtripWorks() { - Price value = new GroupedAllocation() + Price value = new UnitWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5748,6 +6436,7 @@ public void GroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5768,12 +6457,7 @@ public void GroupedAllocationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5809,13 +6493,20 @@ public void GroupedAllocationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5824,27 +6515,21 @@ public void GroupedAllocationSerializationRoundtripWorks() } [Fact] - public void BulkWithProrationSerializationRoundtripWorks() + public void GroupedAllocationSerializationRoundtripWorks() { - Price value = new BulkWithProration() + Price value = new GroupedAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5873,6 +6558,7 @@ public void BulkWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5893,6 +6579,13 @@ public void BulkWithProrationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5928,13 +6621,19 @@ public void BulkWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5943,21 +6642,27 @@ public void BulkWithProrationSerializationRoundtripWorks() } [Fact] - public void GroupedWithProratedMinimumSerializationRoundtripWorks() + public void BulkWithProrationSerializationRoundtripWorks() { - Price value = new GroupedWithProratedMinimum() + Price value = new BulkWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5986,6 +6691,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6006,12 +6712,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6047,13 +6748,19 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6062,21 +6769,21 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMeteredMinimumSerializationRoundtripWorks() + public void GroupedWithProratedMinimumSerializationRoundtripWorks() { - Price value = new GroupedWithMeteredMinimum() + Price value = new GroupedWithProratedMinimum() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, + Cadence = GroupedWithProratedMinimumCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6105,6 +6812,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6125,21 +6833,13 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithProratedMinimumConfig = 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" }, - ], + Minimum = "minimum", + UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6175,13 +6875,19 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6190,21 +6896,21 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void GroupedWithMeteredMinimumSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + Price value = new GroupedWithMeteredMinimum() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, + Cadence = GroupedWithMeteredMinimumCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6233,6 +6939,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6253,141 +6960,24 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() + GroupedWithMeteredMinimumConfig = 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", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MatrixWithDisplayNameSerializationRoundtripWorks() - { - Price value = 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 = + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + ScalingKey = "scaling_key", + UnitAmounts = [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], - Reason = "reason", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -6421,13 +7011,19 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6436,21 +7032,21 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() } [Fact] - public void GroupedTieredPackageSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedTieredPackage() + Price value = new GroupedWithMinMaxThresholds() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6479,6 +7075,7 @@ public void GroupedTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6499,16 +7096,14 @@ public void GroupedTieredPackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6544,13 +7139,19 @@ public void GroupedTieredPackageSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6559,21 +7160,21 @@ public void GroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void MaxGroupTieredPackageSerializationRoundtripWorks() + public void MatrixWithDisplayNameSerializationRoundtripWorks() { - Price value = new MaxGroupTieredPackage() + Price value = new MatrixWithDisplayName() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6602,6 +7203,7 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6622,16 +7224,20 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MaxGroupTieredPackageConfig = new() + MatrixWithDisplayNameConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + Dimension = "dimension", + UnitAmounts = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], }, Maximum = new() @@ -6667,13 +7273,19 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6682,21 +7294,21 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void GroupedTieredPackageSerializationRoundtripWorks() { - Price value = new ScalableMatrixWithUnitPricing() + Price value = new GroupedTieredPackage() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6725,6 +7337,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6745,6 +7358,17 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6780,29 +7404,19 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6811,21 +7425,21 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() } [Fact] - public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void MaxGroupTieredPackageSerializationRoundtripWorks() { - Price value = new ScalableMatrixWithTieredPricing() + Price value = new MaxGroupTieredPackage() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6854,6 +7468,7 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6874,8 +7489,19 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -6909,32 +7535,19 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6943,21 +7556,21 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedBulkSerializationRoundtripWorks() + public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - Price value = new CumulativeGroupedBulk() + Price value = new ScalableMatrixWithUnitPricing() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6986,19 +7599,7 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() Values = ["string"], }, ], - }, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7019,6 +7620,7 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7054,13 +7656,36 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7069,21 +7694,21 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new ScalableMatrixWithTieredPricing() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7112,13 +7737,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], - }, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7139,6 +7758,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7174,13 +7794,38 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], 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 +7834,21 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void CumulativeGroupedBulkSerializationRoundtripWorks() { - Price value = new PriceMinimum() + Price value = new CumulativeGroupedBulk() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7232,6 +7877,20 @@ public void MinimumSerializationRoundtripWorks() 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() @@ -7252,6 +7911,7 @@ public void MinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7285,16 +7945,21 @@ public void MinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7303,21 +7968,21 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void MinimumCompositeSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new MinimumComposite() + Price value = new CumulativeGroupedAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MinimumCompositeBillingMode.InAdvance, - Cadence = MinimumCompositeCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7346,6 +8011,14 @@ public void MinimumCompositeSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7366,6 +8039,7 @@ public void MinimumCompositeSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7399,16 +8073,21 @@ public void MinimumCompositeSerializationRoundtripWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = MinimumCompositePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7417,21 +8096,21 @@ public void MinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - Price value = new Percent() + Price value = new DailyCreditAllowance() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PercentBillingMode.InAdvance, - Cadence = PercentCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PercentCompositePriceFilterField.PriceID, - Operator = PercentCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7460,8 +8139,17 @@ public void PercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -7480,6 +8168,7 @@ public void PercentSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7514,15 +8203,20 @@ public void PercentSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = PercentPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.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); @@ -7531,21 +8225,21 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - Price value = new EventOutput() + Price value = new MeteredAllowance() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = EventOutputBillingMode.InAdvance, - Cadence = EventOutputCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = EventOutputCompositePriceFilterField.PriceID, - Operator = EventOutputCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7574,6 +8268,7 @@ public void EventOutputSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7592,14 +8287,9 @@ public void EventOutputSerializationRoundtripWorks() ], Reason = "reason", }, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7618,6 +8308,15 @@ public void EventOutputSerializationRoundtripWorks() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -7635,39 +8334,42 @@ public void EventOutputSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = EventOutputPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.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 FieldRoundtrip_Works() + public void MinimumCompositeSerializationRoundtripWorks() { - var model = new Unit + Price value = new MinimumComposite() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BillingMode.InAdvance, - Cadence = UnitCadence.OneTime, + BillingMode = MinimumCompositeBillingMode.InAdvance, + Cadence = MinimumCompositeCadence.OneTime, CompositePriceFilters = [ new() { - Field = CompositePriceFilterField.PriceID, - Operator = CompositePriceFilterOperator.Includes, + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7696,6 +8398,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7716,6 +8419,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -7749,187 +8453,167 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = UnitPriceType.UsagePrice, + PriceType = MinimumCompositePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - string expectedID = "id"; - BillableMetricTiny expectedBillableMetric = new("id"); - BillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ApiEnum expectedBillingMode = BillingMode.InAdvance; - ApiEnum expectedCadence = UnitCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() + LicenseType = new() { - Field = CompositePriceFilterField.PriceID, - Operator = CompositePriceFilterOperator.Includes, - Values = ["string"], + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - ]; - 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() + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void PercentSerializationRoundtripWorks() + { + Price value = new Percent() { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = PercentBillingMode.InAdvance, + Cadence = PercentCadence.OneTime, + CompositePriceFilters = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, + Field = PercentCompositePriceFilterField.PriceID, + Operator = PercentCompositePriceFilterOperator.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() + 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() { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", - }; - string expectedMaximumAmount = "maximum_amount"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], + Metadata = 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", + }, }; - 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)); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - 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(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void EventOutputSerializationRoundtripWorks() { - var model = new Unit + Price value = new EventOutput() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BillingMode.InAdvance, - Cadence = UnitCadence.OneTime, + BillingMode = EventOutputBillingMode.InAdvance, + Cadence = EventOutputCadence.OneTime, CompositePriceFilters = [ new() { - Field = CompositePriceFilterField.PriceID, - Operator = CompositePriceFilterOperator.Includes, + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7958,6 +8642,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7976,8 +8661,15 @@ public void SerializationRoundtrip_Works() ], Reason = "reason", }, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8013,24 +8705,31 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitPriceType.UsagePrice, + PriceType = EventOutputPriceType.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); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); - - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } +} +public class UnitTest : TestBase +{ [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void FieldRoundtrip_Works() { var model = new Unit { @@ -8073,6 +8772,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8093,6 +8793,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8136,12 +8837,14 @@ 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); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.NotNull(deserialized); - string expectedID = "id"; BillableMetricTiny expectedBillableMetric = new("id"); BillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8185,6 +8888,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -8205,6 +8909,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -8253,53 +8958,58 @@ 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); - 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); + 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], deserialized.CompositePriceFilters[i]); + Assert.Equal(expectedCompositePriceFilters[i], model.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); + 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(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + 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(deserialized.Metadata.TryGetValue(item.Key, out var value)); + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); + Assert.Equal(value, model.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(expectedUnitConfig, deserialized.UnitConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); + 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); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { var model = new Unit { @@ -8342,6 +9052,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8362,6 +9073,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8405,13 +9117,22 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; - 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 Unit { @@ -8454,6 +9175,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8474,6 +9196,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8512,14 +9235,191 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() 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", + }, }; - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + 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 = 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; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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, 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(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + 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(expectedUnitConfig, deserialized.UnitConfig); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void Validation_Works() { var model = new Unit { @@ -8562,6 +9462,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8582,6 +9483,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8620,13 +9522,24 @@ public void OptionalNullablePropertiesUnsetValidation_Works() 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", + }, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Unit { @@ -8669,6 +9582,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8689,6 +9603,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8727,16 +9642,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() PriceType = UnitPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - - DimensionalPriceConfiguration = null, }; Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new Unit { @@ -8779,6 +9694,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8799,6 +9715,231 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", + 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 }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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 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, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -8839,10 +9980,133 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +10323,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 +10597,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 +10738,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9384,6 +10759,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -9439,6 +10815,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 +10867,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9505,6 +10888,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -9565,6 +10949,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); @@ -9585,6 +10975,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -9605,6 +10996,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 +11043,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9671,6 +11064,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -9726,6 +11120,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 +11178,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9798,6 +11199,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -9853,6 +11255,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 +11311,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9923,6 +11332,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -9983,6 +11393,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); @@ -10003,6 +11419,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -10026,6 +11443,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -10072,6 +11490,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10092,6 +11511,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -10147,6 +11567,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 +11622,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10216,6 +11643,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -10270,6 +11698,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 +11746,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10336,6 +11767,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -10435,6 +11867,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10455,6 +11888,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -10507,10 +11941,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 +11994,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10577,6 +12015,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -10629,10 +12068,145 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +12423,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 +12695,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 +12837,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11173,6 +12858,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -11215,6 +12901,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 +12955,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11283,6 +12976,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -11330,6 +13024,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); @@ -11351,6 +13051,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -11370,6 +13071,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 +13119,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11437,6 +13140,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -11479,6 +13183,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 +13242,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11552,6 +13263,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -11594,6 +13306,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 +13364,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11666,6 +13385,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -11713,6 +13433,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); @@ -11734,6 +13460,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -11756,6 +13483,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -11803,6 +13531,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11823,6 +13552,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -11865,6 +13595,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 +13651,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11935,6 +13672,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -11976,6 +13714,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 +13763,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12043,6 +13784,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -12130,6 +13872,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12150,6 +13893,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -12189,10 +13933,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 +13987,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12260,6 +14008,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -12299,10 +14048,133 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +14391,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 +14663,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 +14813,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12851,6 +14834,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -12893,6 +14877,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 +14939,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -12969,6 +14960,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -13017,6 +15009,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); @@ -13038,6 +15036,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -13057,6 +15056,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 +15112,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13132,6 +15133,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13174,6 +15176,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 +15246,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13258,6 +15267,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13300,6 +15310,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 +15379,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13383,6 +15400,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -13431,6 +15449,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); @@ -13452,6 +15476,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -13474,6 +15499,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -13529,6 +15555,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13549,6 +15576,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13591,6 +15619,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 +15683,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13669,6 +15704,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13710,6 +15746,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 +15803,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13785,6 +15824,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13880,6 +15920,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13900,6 +15941,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -13939,10 +15981,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 +16043,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14018,6 +16064,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -14057,10 +16104,141 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +16415,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 +16489,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 +16615,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 +16787,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 +17055,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 +17196,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14886,6 +17217,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -14929,6 +17261,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 +17313,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -14995,6 +17334,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -15047,6 +17387,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); @@ -15067,6 +17413,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -15087,6 +17434,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 +17481,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15153,6 +17502,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15196,6 +17546,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 +17604,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15268,6 +17625,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15311,6 +17669,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 +17728,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15384,6 +17749,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -15436,6 +17802,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); @@ -15456,6 +17828,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -15479,6 +17852,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -15525,6 +17899,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15545,6 +17920,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15588,6 +17964,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 +18019,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15657,6 +18040,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15699,6 +18083,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 +18131,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15765,6 +18152,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15852,6 +18240,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15872,6 +18261,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -15912,10 +18302,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 +18355,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15982,6 +18376,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -16022,10 +18417,133 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +18760,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 +19030,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 +19171,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16563,6 +19192,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -16611,6 +19241,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 +19293,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -16677,6 +19314,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -16730,6 +19368,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); @@ -16750,6 +19394,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMatrixConfig, model.MatrixConfig); @@ -16770,6 +19415,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 +19462,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16836,6 +19483,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -16884,6 +19532,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 +19590,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16956,6 +19611,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17004,6 +19660,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 +19716,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -17074,6 +19737,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -17127,6 +19791,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); @@ -17147,6 +19817,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMatrixConfig, deserialized.MatrixConfig); @@ -17170,6 +19841,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -17216,6 +19888,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17236,6 +19909,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17284,6 +19958,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 +20013,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17353,6 +20034,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17400,6 +20082,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 +20130,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17466,6 +20151,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17558,6 +20244,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17578,6 +20265,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17623,10 +20311,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 +20364,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17693,6 +20385,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixConfig = new() @@ -17738,10 +20431,138 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +20779,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 +21051,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 +21192,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18281,6 +21213,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -18332,6 +21265,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 +21319,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18400,6 +21340,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -18457,6 +21398,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); @@ -18477,6 +21424,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -18497,6 +21445,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 +21492,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18563,6 +21513,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -18614,6 +21565,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 +21626,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18689,6 +21647,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -18740,6 +21699,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 +21760,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18815,6 +21781,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -18872,6 +21839,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); @@ -18892,6 +21865,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -18915,6 +21889,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -18961,6 +21936,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18981,6 +21957,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -19032,6 +22009,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 +22064,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19101,6 +22085,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -19151,6 +22136,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 +22184,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19217,6 +22205,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -19312,6 +22301,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19332,6 +22322,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -19380,10 +22371,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 +22424,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19450,6 +22445,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -19498,10 +22494,141 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +22843,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 +23281,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 +23373,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 +23530,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20281,6 +23551,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -20332,6 +23603,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 +23656,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20399,6 +23677,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -20456,6 +23735,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); @@ -20476,6 +23761,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -20496,6 +23782,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 +23829,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20562,6 +23850,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -20613,6 +23902,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 +23963,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20688,6 +23984,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -20739,6 +24036,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 +24096,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20813,6 +24117,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -20870,6 +24175,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); @@ -20890,6 +24201,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -20913,6 +24225,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -20959,6 +24272,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20979,6 +24293,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -21030,6 +24345,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 +24400,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21099,6 +24421,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -21149,6 +24472,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 +24520,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21215,6 +24541,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -21310,6 +24637,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21330,6 +24658,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -21378,10 +24707,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 +24760,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21448,6 +24781,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -21496,10 +24830,141 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +25181,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 +25551,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 +25641,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 +25798,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22211,6 +25819,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -22273,6 +25882,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 +25936,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22341,6 +25957,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -22409,6 +26026,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); @@ -22429,6 +26052,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -22449,6 +26073,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 +26120,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22515,6 +26141,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -22577,6 +26204,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 +26265,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22652,6 +26286,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -22714,6 +26349,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 +26410,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22789,6 +26431,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -22857,6 +26500,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); @@ -22877,6 +26526,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -22900,6 +26550,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -22946,6 +26597,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22966,6 +26618,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -23028,258 +26681,11 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new TieredWithMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithMinimumBillingMode.InAdvance, - Cadence = TieredWithMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() + LicenseType = new() { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = TieredWithMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new TieredWithMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithMinimumBillingMode.InAdvance, - Cadence = TieredWithMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = TieredWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = TieredWithMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -23287,7 +26693,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new TieredWithMinimum { @@ -23330,6 +26736,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23350,6 +26757,266 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = TieredWithMinimumPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + }; + + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredWithMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = TieredWithMinimumPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new TieredWithMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + 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, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -23409,10 +27076,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 +27129,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23479,6 +27150,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -23538,10 +27210,152 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +27570,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 +28122,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 +28231,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 +28389,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24450,6 +28419,7 @@ public void FieldRoundtrip_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -24492,6 +28462,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 +28515,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -24568,6 +28545,7 @@ public void FieldRoundtrip_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -24616,6 +28594,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); @@ -24637,6 +28621,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedGroupedTieredConfig, model.GroupedTieredConfig); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -24656,6 +28641,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 +28688,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24731,6 +28718,7 @@ public void SerializationRoundtrip_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -24773,6 +28761,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 +28822,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24857,6 +28852,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -24899,6 +28895,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 +28955,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -24982,6 +28985,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -25030,6 +29034,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); @@ -25051,6 +29061,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedGroupedTieredConfig, deserialized.GroupedTieredConfig); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -25073,6 +29084,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -25119,6 +29131,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25148,6 +29161,7 @@ public void Validation_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -25190,6 +29204,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 +29259,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25268,6 +29289,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -25309,6 +29331,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 +29379,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25384,6 +29409,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -25470,6 +29496,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25499,6 +29526,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -25538,10 +29566,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 +29619,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25617,6 +29649,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -25656,10 +29689,141 @@ 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +30040,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 +30350,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 +30440,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 +30516,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 +30657,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26371,6 +30678,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -26432,6 +30740,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 +30794,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26500,6 +30815,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -26570,6 +30886,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); @@ -26590,6 +30912,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -26610,6 +30933,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 +30980,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26676,6 +31001,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -26737,6 +31063,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 +31124,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26812,6 +31145,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -26873,6 +31207,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 +31268,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26948,6 +31289,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -27018,6 +31360,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); @@ -27038,6 +31386,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -27064,6 +31413,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -27110,6 +31460,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27130,6 +31481,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -27191,6 +31543,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 +31598,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27260,6 +31619,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -27320,6 +31680,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 +31728,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27386,6 +31749,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -27491,6 +31855,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27511,6 +31876,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -27569,10 +31935,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 +31988,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27639,6 +32009,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -27697,10 +32068,151 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +32423,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 +32857,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 +32967,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 +33125,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28480,6 +33146,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -28528,6 +33195,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 +33249,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -28596,6 +33270,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -28652,6 +33327,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); @@ -28672,6 +33353,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -28692,6 +33374,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 +33421,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28758,6 +33442,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -28806,6 +33491,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 +33552,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28881,6 +33573,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -28929,6 +33622,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 +33683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -29004,6 +33704,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -29060,6 +33761,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); @@ -29080,6 +33787,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -29103,6 +33811,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -29149,6 +33858,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29169,6 +33879,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -29217,6 +33928,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 +33983,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29286,6 +34004,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -29333,6 +34052,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 +34100,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29399,6 +34121,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -29491,6 +34214,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29511,6 +34235,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -29556,10 +34281,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 +34334,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29626,6 +34355,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -29671,10 +34401,138 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +34745,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 +35037,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 +35112,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 +35253,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30290,6 +35274,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -30333,6 +35318,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 +35371,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30400,6 +35392,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -30453,6 +35446,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); @@ -30473,6 +35472,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -30493,6 +35493,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 +35540,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30559,6 +35561,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -30602,6 +35605,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 +35666,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30677,6 +35687,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -30720,6 +35731,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 +35791,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30794,6 +35812,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -30847,6 +35866,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); @@ -30867,6 +35892,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -30890,6 +35916,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -30936,6 +35963,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30956,6 +35984,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -30999,228 +36028,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 +36083,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31283,6 +36104,228 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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() + { + 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, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -31323,10 +36366,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 +36419,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31393,6 +36440,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -31433,10 +36481,133 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +36824,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 +37162,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 +37319,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32044,6 +37340,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -32093,6 +37390,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 +37444,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32161,6 +37465,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -32216,6 +37521,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); @@ -32236,6 +37547,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMatrixWithAllocationConfig, model.MatrixWithAllocationConfig); @@ -32256,6 +37568,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 +37615,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32322,6 +37636,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -32371,6 +37686,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 +37747,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32446,6 +37768,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -32495,6 +37818,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 +37879,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32570,6 +37900,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -32625,6 +37956,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); @@ -32645,6 +37982,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMatrixWithAllocationConfig, deserialized.MatrixWithAllocationConfig); @@ -32668,6 +38006,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -32714,6 +38053,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32734,6 +38074,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -32783,6 +38124,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 +38179,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32852,6 +38200,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -32900,6 +38249,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 +38297,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32966,6 +38318,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -33059,6 +38412,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33079,6 +38433,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -33125,10 +38480,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 +38533,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33195,6 +38554,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, MatrixWithAllocationConfig = new() @@ -33241,10 +38601,139 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +38948,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,24 +39216,119 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationTest : TestBase +public class MatrixWithAllocationLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + 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 MatrixWithThresholdDiscountsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -33758,6 +39357,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33778,8 +39378,35 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -33813,16 +39440,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.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", + }, }; string expectedID = "id"; @@ -33832,21 +39462,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - TieredWithProrationBillingMode.InAdvance; - ApiEnum expectedCadence = - TieredWithProrationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MatrixWithThresholdDiscountsBillingMode.InAdvance; + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -33871,6 +39501,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -33891,12 +39522,39 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -33928,20 +39586,25 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - TieredWithProrationPriceType.UsagePrice; + ApiEnum expectedPriceType = + MatrixWithThresholdDiscountsPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - TieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithThresholdDiscountsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -33962,8 +39625,13 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); Assert.Equal(expectedMaximum, model.Maximum); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); @@ -33980,26 +39648,26 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34028,6 +39696,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34048,8 +39717,35 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34083,20 +39779,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -34107,19 +39806,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34148,6 +39847,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34168,8 +39868,35 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34203,20 +39930,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -34229,21 +39959,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - TieredWithProrationBillingMode.InAdvance; - ApiEnum expectedCadence = - TieredWithProrationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MatrixWithThresholdDiscountsBillingMode.InAdvance; + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -34268,6 +39998,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -34288,12 +40019,39 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -34325,20 +40083,25 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - TieredWithProrationPriceType.UsagePrice; + ApiEnum expectedPriceType = + MatrixWithThresholdDiscountsPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - TieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithThresholdDiscountsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -34359,8 +40122,13 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); Assert.Equal(expectedMaximum, deserialized.Maximum); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); @@ -34377,29 +40145,29 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceType, deserialized.PriceType); Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal( expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34428,6 +40196,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34448,8 +40217,35 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34483,16 +40279,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.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", + }, }; model.Validate(); @@ -34501,19 +40300,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34542,6 +40341,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34562,8 +40362,35 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34597,33 +40424,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", 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 TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34652,6 +40478,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34672,8 +40499,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34707,11 +40561,8 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -34720,19 +40571,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34761,6 +40612,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34781,8 +40633,35 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34816,35 +40695,35 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", 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] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = new MatrixWithThresholdDiscounts { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -34873,6 +40752,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34893,8 +40773,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -34928,54 +40835,198 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = MatrixWithThresholdDiscountsPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscounts + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithThresholdDiscountsBillingMode.InAdvance, + Cadence = MatrixWithThresholdDiscountsCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.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, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Maximum = new() + { + AppliesToPriceIds = ["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 = MatrixWithThresholdDiscountsPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationBillingModeTest : TestBase +public class MatrixWithThresholdDiscountsBillingModeTest : TestBase { [Theory] - [InlineData(TieredWithProrationBillingMode.InAdvance)] - [InlineData(TieredWithProrationBillingMode.InArrear)] - public void Validation_Works(TieredWithProrationBillingMode rawValue) + [InlineData(MatrixWithThresholdDiscountsBillingMode.InAdvance)] + [InlineData(MatrixWithThresholdDiscountsBillingMode.InArrear)] + public void Validation_Works(MatrixWithThresholdDiscountsBillingMode 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(TieredWithProrationBillingMode.InAdvance)] - [InlineData(TieredWithProrationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(TieredWithProrationBillingMode rawValue) + [InlineData(MatrixWithThresholdDiscountsBillingMode.InAdvance)] + [InlineData(MatrixWithThresholdDiscountsBillingMode.InArrear)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsBillingMode 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); @@ -34984,64 +41035,61 @@ public void SerializationRoundtrip_Works(TieredWithProrationBillingMode rawValue [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class TieredWithProrationCadenceTest : TestBase +public class MatrixWithThresholdDiscountsCadenceTest : TestBase { [Theory] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.Custom)] - public void Validation_Works(TieredWithProrationCadence rawValue) + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(MatrixWithThresholdDiscountsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsCadence 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); } @@ -35049,36 +41097,34 @@ public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class TieredWithProrationCompositePriceFilterTest : TestBase +public class MatrixWithThresholdDiscountsCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationCompositePriceFilter + var model = new MatrixWithThresholdDiscountsCompositePriceFilter { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - TieredWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - TieredWithProrationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -35093,18 +41139,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationCompositePriceFilter + var model = new MatrixWithThresholdDiscountsCompositePriceFilter { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -35112,24 +41159,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationCompositePriceFilter + var model = new MatrixWithThresholdDiscountsCompositePriceFilter { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedField = - TieredWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - TieredWithProrationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -35144,29 +41192,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProrationCompositePriceFilter + var model = new MatrixWithThresholdDiscountsCompositePriceFilter { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, Values = ["string"], }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsCompositePriceFilter + { + Field = MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + Operator = MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixWithThresholdDiscountsCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationCompositePriceFilterFieldTest : TestBase +public class MatrixWithThresholdDiscountsCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(TieredWithProrationCompositePriceFilterField.PriceID)] - [InlineData(TieredWithProrationCompositePriceFilterField.ItemID)] - [InlineData(TieredWithProrationCompositePriceFilterField.PriceType)] - [InlineData(TieredWithProrationCompositePriceFilterField.Currency)] - [InlineData(TieredWithProrationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(TieredWithProrationCompositePriceFilterField rawValue) + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.ItemID)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PriceType)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.Currency)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(MatrixWithThresholdDiscountsCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -35174,7 +41237,7 @@ public void Validation_Works(TieredWithProrationCompositePriceFilterField rawVal public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -35182,19 +41245,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCompositePriceFilterField.PriceID)] - [InlineData(TieredWithProrationCompositePriceFilterField.ItemID)] - [InlineData(TieredWithProrationCompositePriceFilterField.PriceType)] - [InlineData(TieredWithProrationCompositePriceFilterField.Currency)] - [InlineData(TieredWithProrationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(TieredWithProrationCompositePriceFilterField rawValue) + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.ItemID)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PriceType)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.Currency)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + MatrixWithThresholdDiscountsCompositePriceFilterField 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); @@ -35204,26 +41269,26 @@ public void SerializationRoundtrip_Works(TieredWithProrationCompositePriceFilter 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 TieredWithProrationCompositePriceFilterOperatorTest : TestBase +public class MatrixWithThresholdDiscountsCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(TieredWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(TieredWithProrationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(TieredWithProrationCompositePriceFilterOperator rawValue) + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterOperator.Excludes)] + public void Validation_Works(MatrixWithThresholdDiscountsCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -35231,7 +41296,7 @@ public void Validation_Works(TieredWithProrationCompositePriceFilterOperator raw public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -35239,18 +41304,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(TieredWithProrationCompositePriceFilterOperator.Excludes)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes)] + [InlineData(MatrixWithThresholdDiscountsCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - TieredWithProrationCompositePriceFilterOperator rawValue + MatrixWithThresholdDiscountsCompositePriceFilterOperator 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); @@ -35260,63 +41325,67 @@ TieredWithProrationCompositePriceFilterOperator 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 TieredWithProrationConversionRateConfigTest : TestBase +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + MatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + MatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + MatrixWithThresholdDiscountsConversionRateConfig 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); } @@ -35324,120 +41393,136 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + MatrixWithThresholdDiscountsConversionRateConfig 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 TieredWithProrationPriceTypeTest : TestBase -{ - [Theory] - [InlineData(TieredWithProrationPriceType.UsagePrice)] - [InlineData(TieredWithProrationPriceType.FixedPrice)] - [InlineData(TieredWithProrationPriceType.CompositePrice)] - public void Validation_Works(TieredWithProrationPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(TieredWithProrationPriceType.UsagePrice)] - [InlineData(TieredWithProrationPriceType.FixedPrice)] - [InlineData(TieredWithProrationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(TieredWithProrationPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(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); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class TieredWithProrationTieredWithProrationConfigTest : TestBase +public class MatrixWithThresholdDiscountsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationTieredWithProrationConfig + var model = new MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - List expectedTiers = + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ]; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) { - Assert.Equal(expectedTiers[i], model.Tiers[i]); + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationTieredWithProrationConfig + var model = new MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -35448,497 +41533,812 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationTieredWithProrationConfig + var model = new MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ]; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); } } [Fact] public void Validation_Works() { - var model = new TieredWithProrationTieredWithProrationConfig + var model = new MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; model.Validate(); } -} -public class TieredWithProrationTieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationTieredWithProrationConfigTier + var model = new MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProrationTieredWithProrationConfigTier + var model = new MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - 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 OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new TieredWithProrationTieredWithProrationConfigTier + var model = new MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void Validation_Works() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationTieredWithProrationConfigTier + var model = new MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; model.Validate(); } -} -public class UnitWithProrationTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnitWithProration + var model = new MatrixWithThresholdDiscountsConfig { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, - CompositePriceFilters = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - 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() + ThresholdDiscountGroups = + [ + new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, + ], }; - string expectedID = "id"; - BillableMetricTiny expectedBillableMetric = new("id"); - BillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ApiEnum expectedBillingMode = - UnitWithProrationBillingMode.InAdvance; - ApiEnum expectedCadence = - UnitWithProrationCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - UnitWithProrationConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Allocation expectedCreditAllocation = new() + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - }; - string expectedCurrency = "currency"; - SharedDiscount expectedDiscount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = + ThresholdDiscountGroups = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - 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() + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - AppliesToPriceIds = ["string"], - Filters = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - MaximumAmount = "maximum_amount", - }; - string expectedMaximumAmount = "maximum_amount"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = + ThresholdDiscountGroups = [ new() { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - MinimumAmount = "minimum_amount", - }; - string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - UnitWithProrationPriceType.UsagePrice; - string expectedReplacesPriceID = "replaces_price_id"; - UnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = new( - "unit_amount" - ); - DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", + + SecondDimension = null, }; - 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.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], - 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(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + SecondDimension = null, + }; + + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new UnitWithProration + var model = new MatrixWithThresholdDiscountsConfig { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, - CompositePriceFilters = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, ], - 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() + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - 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", + ], + }; + + MatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixWithThresholdDiscountsConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdDiscountGroupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ThresholdDiscountGroup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsPriceTypeTest : TestBase +{ + [Theory] + [InlineData(MatrixWithThresholdDiscountsPriceType.UsagePrice)] + [InlineData(MatrixWithThresholdDiscountsPriceType.FixedPrice)] + [InlineData(MatrixWithThresholdDiscountsPriceType.CompositePrice)] + public void Validation_Works(MatrixWithThresholdDiscountsPriceType rawValue) + { + // force 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(MatrixWithThresholdDiscountsPriceType.UsagePrice)] + [InlineData(MatrixWithThresholdDiscountsPriceType.FixedPrice)] + [InlineData(MatrixWithThresholdDiscountsPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class MatrixWithThresholdDiscountsLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsLicenseType + { + 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 MatrixWithThresholdDiscountsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", Name = "name", - PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -35949,19 +42349,76 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnitWithProration + var model = new MatrixWithThresholdDiscountsLicenseType + { + 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 MatrixWithThresholdDiscountsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixWithThresholdDiscountsLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -35990,6 +42447,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36010,6 +42468,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36045,23 +42504,24 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + 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", + }, }; - 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() @@ -36069,21 +42529,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - UnitWithProrationBillingMode.InAdvance; - ApiEnum expectedCadence = - UnitWithProrationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + TieredWithProrationBillingMode.InAdvance; + ApiEnum expectedCadence = + TieredWithProrationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - UnitWithProrationConversionRateConfig expectedConversionRateConfig = + TieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -36108,6 +42568,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -36128,6 +42589,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -36165,81 +42627,86 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - UnitWithProrationPriceType.UsagePrice; + ApiEnum expectedPriceType = + TieredWithProrationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - UnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = new( - "unit_amount" + TieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] ); DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); - 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); + 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], deserialized.CompositePriceFilters[i]); + Assert.Equal(expectedCompositePriceFilters[i], model.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); + 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(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + 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(deserialized.Metadata.TryGetValue(item.Key, out var value)); + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); + Assert.Equal(value, model.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(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); + 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { - var model = new UnitWithProration + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -36268,6 +42735,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36288,6 +42756,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36323,14 +42792,448 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + 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", + }, + }; + + string json = 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 + { + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + 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 = + TieredWithProrationBillingMode.InAdvance; + ApiEnum expectedCadence = + TieredWithProrationCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + TieredWithProrationConversionRateConfig 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; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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("tiered_with_proration"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + TieredWithProrationPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + TieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); + } + + [Fact] + public void Validation_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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, }; model.Validate(); @@ -36339,19 +43242,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new UnitWithProration + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -36380,6 +43283,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36400,6 +43304,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36435,31 +43340,35 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", 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 UnitWithProration + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -36488,6 +43397,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36508,6 +43418,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36543,9 +43454,11 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -36554,19 +43467,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new UnitWithProration + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -36595,6 +43508,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36615,6 +43529,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36650,33 +43565,38 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", 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] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new UnitWithProration + var model = new TieredWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -36705,6 +43625,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36725,6 +43646,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -36760,35 +43682,162 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } -} - -public class UnitWithProrationBillingModeTest : TestBase -{ - [Theory] - [InlineData(UnitWithProrationBillingMode.InAdvance)] - [InlineData(UnitWithProrationBillingMode.InArrear)] - public void Validation_Works(UnitWithProrationBillingMode rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +{ + [Theory] + [InlineData(TieredWithProrationBillingMode.InAdvance)] + [InlineData(TieredWithProrationBillingMode.InArrear)] + public void Validation_Works(TieredWithProrationBillingMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions ); Assert.NotNull(value); @@ -36796,16 +43845,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnitWithProrationBillingMode.InAdvance)] - [InlineData(UnitWithProrationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(UnitWithProrationBillingMode rawValue) + [InlineData(TieredWithProrationBillingMode.InAdvance)] + [InlineData(TieredWithProrationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(TieredWithProrationBillingMode 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); @@ -36814,39 +43863,39 @@ public void SerializationRoundtrip_Works(UnitWithProrationBillingMode 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 UnitWithProrationCadenceTest : TestBase +public class TieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(UnitWithProrationCadence.OneTime)] - [InlineData(UnitWithProrationCadence.Monthly)] - [InlineData(UnitWithProrationCadence.Quarterly)] - [InlineData(UnitWithProrationCadence.SemiAnnual)] - [InlineData(UnitWithProrationCadence.Annual)] - [InlineData(UnitWithProrationCadence.Custom)] - public void Validation_Works(UnitWithProrationCadence rawValue) + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.Custom)] + public void Validation_Works(TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -36856,19 +43905,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnitWithProrationCadence.OneTime)] - [InlineData(UnitWithProrationCadence.Monthly)] - [InlineData(UnitWithProrationCadence.Quarterly)] - [InlineData(UnitWithProrationCadence.SemiAnnual)] - [InlineData(UnitWithProrationCadence.Annual)] - [InlineData(UnitWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(UnitWithProrationCadence rawValue) + [InlineData(TieredWithProrationCadence.OneTime)] + [InlineData(TieredWithProrationCadence.Monthly)] + [InlineData(TieredWithProrationCadence.Quarterly)] + [InlineData(TieredWithProrationCadence.SemiAnnual)] + [InlineData(TieredWithProrationCadence.Annual)] + [InlineData(TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -36879,12 +43928,12 @@ public void SerializationRoundtrip_Works(UnitWithProrationCadence 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 ); @@ -36893,22 +43942,22 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class UnitWithProrationCompositePriceFilterTest : TestBase +public class TieredWithProrationCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnitWithProrationCompositePriceFilter + var model = new TieredWithProrationCompositePriceFilter { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - UnitWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - UnitWithProrationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + TieredWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + TieredWithProrationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -36923,15 +43972,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new UnitWithProrationCompositePriceFilter + var model = new TieredWithProrationCompositePriceFilter { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -36942,24 +43991,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnitWithProrationCompositePriceFilter + var model = new TieredWithProrationCompositePriceFilter { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - UnitWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - UnitWithProrationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + TieredWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + TieredWithProrationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -36974,29 +44023,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new UnitWithProrationCompositePriceFilter + var model = new TieredWithProrationCompositePriceFilter { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 UnitWithProrationCompositePriceFilterFieldTest : TestBase +public class TieredWithProrationCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(UnitWithProrationCompositePriceFilterField.PriceID)] - [InlineData(UnitWithProrationCompositePriceFilterField.ItemID)] - [InlineData(UnitWithProrationCompositePriceFilterField.PriceType)] - [InlineData(UnitWithProrationCompositePriceFilterField.Currency)] - [InlineData(UnitWithProrationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(UnitWithProrationCompositePriceFilterField rawValue) + [InlineData(TieredWithProrationCompositePriceFilterField.PriceID)] + [InlineData(TieredWithProrationCompositePriceFilterField.ItemID)] + [InlineData(TieredWithProrationCompositePriceFilterField.PriceType)] + [InlineData(TieredWithProrationCompositePriceFilterField.Currency)] + [InlineData(TieredWithProrationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(TieredWithProrationCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -37004,7 +44068,7 @@ public void Validation_Works(UnitWithProrationCompositePriceFilterField rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -37012,19 +44076,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnitWithProrationCompositePriceFilterField.PriceID)] - [InlineData(UnitWithProrationCompositePriceFilterField.ItemID)] - [InlineData(UnitWithProrationCompositePriceFilterField.PriceType)] - [InlineData(UnitWithProrationCompositePriceFilterField.Currency)] - [InlineData(UnitWithProrationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterField rawValue) + [InlineData(TieredWithProrationCompositePriceFilterField.PriceID)] + [InlineData(TieredWithProrationCompositePriceFilterField.ItemID)] + [InlineData(TieredWithProrationCompositePriceFilterField.PriceType)] + [InlineData(TieredWithProrationCompositePriceFilterField.Currency)] + [InlineData(TieredWithProrationCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(TieredWithProrationCompositePriceFilterField 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); @@ -37034,26 +44098,26 @@ public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterFi 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 UnitWithProrationCompositePriceFilterOperatorTest : TestBase +public class TieredWithProrationCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(UnitWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(UnitWithProrationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(UnitWithProrationCompositePriceFilterOperator rawValue) + [InlineData(TieredWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(TieredWithProrationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(TieredWithProrationCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -37061,7 +44125,7 @@ public void Validation_Works(UnitWithProrationCompositePriceFilterOperator rawVa public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -37069,16 +44133,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnitWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(UnitWithProrationCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterOperator rawValue) + [InlineData(TieredWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(TieredWithProrationCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + TieredWithProrationCompositePriceFilterOperator 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); @@ -37088,23 +44154,23 @@ public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterOp 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 UnitWithProrationConversionRateConfigTest : TestBase +public class TieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - UnitWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() + TieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -37115,7 +44181,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - UnitWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() + TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -37135,13 +44201,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - UnitWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() + TieredWithProrationConversionRateConfig 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 ); @@ -37152,7 +44218,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - UnitWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() + TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -37167,7 +44233,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -37176,23 +44242,23 @@ public void TieredSerializationRoundtripWorks() } } -public class UnitWithProrationPriceTypeTest : TestBase +public class TieredWithProrationPriceTypeTest : TestBase { [Theory] - [InlineData(UnitWithProrationPriceType.UsagePrice)] - [InlineData(UnitWithProrationPriceType.FixedPrice)] - [InlineData(UnitWithProrationPriceType.CompositePrice)] - public void Validation_Works(UnitWithProrationPriceType rawValue) + [InlineData(TieredWithProrationPriceType.UsagePrice)] + [InlineData(TieredWithProrationPriceType.FixedPrice)] + [InlineData(TieredWithProrationPriceType.CompositePrice)] + public void Validation_Works(TieredWithProrationPriceType 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 ); @@ -37202,19 +44268,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(UnitWithProrationPriceType.UsagePrice)] - [InlineData(UnitWithProrationPriceType.FixedPrice)] - [InlineData(UnitWithProrationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(UnitWithProrationPriceType rawValue) + [InlineData(TieredWithProrationPriceType.UsagePrice)] + [InlineData(TieredWithProrationPriceType.FixedPrice)] + [InlineData(TieredWithProrationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(TieredWithProrationPriceType 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); } @@ -37222,39 +44287,51 @@ public void SerializationRoundtrip_Works(UnitWithProrationPriceType 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 UnitWithProrationUnitWithProrationConfigTest : TestBase +public class TieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + var model = new TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedUnitAmount = "unit_amount"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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 UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + var model = new TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -37265,47 +44342,256 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + var model = new TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + 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 TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationTieredWithProrationConfigTier + { + 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 TieredWithProrationTieredWithProrationConfigTier + { + 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 TieredWithProrationTieredWithProrationConfigTier + { + 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 UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + var model = new TieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; 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 GroupedAllocationTest : TestBase +public class TieredWithProrationLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedAllocation + var model = new TieredWithProrationLicenseType { ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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 = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -37334,6 +44620,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37354,12 +44641,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -37395,13 +44677,20 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -37411,21 +44700,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedAllocationBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedAllocationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + UnitWithProrationBillingMode.InAdvance; + ApiEnum expectedCadence = + UnitWithProrationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedAllocationConversionRateConfig expectedConversionRateConfig = + UnitWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -37450,6 +44739,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37470,12 +44760,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -37513,17 +44798,26 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedAllocationPriceType.UsagePrice; + ApiEnum expectedPriceType = + UnitWithProrationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; + UnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = new( + "unit_amount" + ); DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -37544,7 +44838,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -37563,25 +44857,27 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -37610,6 +44906,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37630,12 +44927,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -37671,17 +44963,24 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -37692,19 +44991,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -37733,6 +45032,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37753,12 +45053,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -37794,17 +45089,24 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -37817,21 +45119,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedAllocationBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedAllocationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + UnitWithProrationBillingMode.InAdvance; + ApiEnum expectedCadence = + UnitWithProrationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedAllocationConversionRateConfig expectedConversionRateConfig = + UnitWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -37856,6 +45158,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37876,12 +45179,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -37919,17 +45217,26 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_proration"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedAllocationPriceType.UsagePrice; + ApiEnum expectedPriceType = + UnitWithProrationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; + UnitWithProrationUnitWithProrationConfig expectedUnitWithProrationConfig = new( + "unit_amount" + ); DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -37950,7 +45257,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -37969,28 +45276,30 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceType, deserialized.PriceType); Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal(expectedUnitWithProrationConfig, deserialized.UnitWithProrationConfig); Assert.Equal( expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -38019,6 +45328,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38039,12 +45349,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -38080,13 +45385,20 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + 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", + }, }; model.Validate(); @@ -38095,19 +45407,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -38136,6 +45448,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38156,12 +45469,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -38197,30 +45505,33 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + PriceType = UnitWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + UnitWithProrationConfig = new("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 GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -38249,6 +45560,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38269,12 +45581,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -38310,8 +45617,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + PriceType = UnitWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + UnitWithProrationConfig = new("unit_amount"), }; model.Validate(); @@ -38320,19 +45628,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -38361,6 +45669,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38381,12 +45690,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -38422,32 +45726,36 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + PriceType = UnitWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + 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] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedAllocation + var model = new UnitWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -38476,6 +45784,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38496,12 +45805,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -38537,32 +45841,156 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + PriceType = UnitWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 GroupedAllocationBillingModeTest : TestBase +public class UnitWithProrationBillingModeTest : TestBase { [Theory] - [InlineData(GroupedAllocationBillingMode.InAdvance)] - [InlineData(GroupedAllocationBillingMode.InArrear)] - public void Validation_Works(GroupedAllocationBillingMode rawValue) + [InlineData(UnitWithProrationBillingMode.InAdvance)] + [InlineData(UnitWithProrationBillingMode.InArrear)] + public void Validation_Works(UnitWithProrationBillingMode 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 ); @@ -38572,16 +46000,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedAllocationBillingMode.InAdvance)] - [InlineData(GroupedAllocationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(GroupedAllocationBillingMode rawValue) + [InlineData(UnitWithProrationBillingMode.InAdvance)] + [InlineData(UnitWithProrationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(UnitWithProrationBillingMode 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); @@ -38590,39 +46018,39 @@ public void SerializationRoundtrip_Works(GroupedAllocationBillingMode 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 GroupedAllocationCadenceTest : TestBase +public class UnitWithProrationCadenceTest : TestBase { [Theory] - [InlineData(GroupedAllocationCadence.OneTime)] - [InlineData(GroupedAllocationCadence.Monthly)] - [InlineData(GroupedAllocationCadence.Quarterly)] - [InlineData(GroupedAllocationCadence.SemiAnnual)] - [InlineData(GroupedAllocationCadence.Annual)] - [InlineData(GroupedAllocationCadence.Custom)] - public void Validation_Works(GroupedAllocationCadence rawValue) + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.Custom)] + public void Validation_Works(UnitWithProrationCadence 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 ); @@ -38632,19 +46060,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedAllocationCadence.OneTime)] - [InlineData(GroupedAllocationCadence.Monthly)] - [InlineData(GroupedAllocationCadence.Quarterly)] - [InlineData(GroupedAllocationCadence.SemiAnnual)] - [InlineData(GroupedAllocationCadence.Annual)] - [InlineData(GroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedAllocationCadence rawValue) + [InlineData(UnitWithProrationCadence.OneTime)] + [InlineData(UnitWithProrationCadence.Monthly)] + [InlineData(UnitWithProrationCadence.Quarterly)] + [InlineData(UnitWithProrationCadence.SemiAnnual)] + [InlineData(UnitWithProrationCadence.Annual)] + [InlineData(UnitWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(UnitWithProrationCadence 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 ); @@ -38655,12 +46083,12 @@ public void SerializationRoundtrip_Works(GroupedAllocationCadence 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 ); @@ -38669,22 +46097,22 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class GroupedAllocationCompositePriceFilterTest : TestBase +public class UnitWithProrationCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedAllocationCompositePriceFilter + var model = new UnitWithProrationCompositePriceFilter { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - GroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedAllocationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + UnitWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + UnitWithProrationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -38699,15 +46127,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedAllocationCompositePriceFilter + var model = new UnitWithProrationCompositePriceFilter { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -38718,24 +46146,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedAllocationCompositePriceFilter + var model = new UnitWithProrationCompositePriceFilter { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - GroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedAllocationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + UnitWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + UnitWithProrationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -38750,29 +46178,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedAllocationCompositePriceFilter + var model = new UnitWithProrationCompositePriceFilter { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 GroupedAllocationCompositePriceFilterFieldTest : TestBase +public class UnitWithProrationCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(GroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(GroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(GroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(GroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(GroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(GroupedAllocationCompositePriceFilterField rawValue) + [InlineData(UnitWithProrationCompositePriceFilterField.PriceID)] + [InlineData(UnitWithProrationCompositePriceFilterField.ItemID)] + [InlineData(UnitWithProrationCompositePriceFilterField.PriceType)] + [InlineData(UnitWithProrationCompositePriceFilterField.Currency)] + [InlineData(UnitWithProrationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(UnitWithProrationCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -38780,7 +46223,7 @@ public void Validation_Works(GroupedAllocationCompositePriceFilterField rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -38788,19 +46231,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(GroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(GroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(GroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(GroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterField rawValue) + [InlineData(UnitWithProrationCompositePriceFilterField.PriceID)] + [InlineData(UnitWithProrationCompositePriceFilterField.ItemID)] + [InlineData(UnitWithProrationCompositePriceFilterField.PriceType)] + [InlineData(UnitWithProrationCompositePriceFilterField.Currency)] + [InlineData(UnitWithProrationCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterField 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); @@ -38810,26 +46253,26 @@ public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterFi 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 GroupedAllocationCompositePriceFilterOperatorTest : TestBase +public class UnitWithProrationCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(GroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(GroupedAllocationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(GroupedAllocationCompositePriceFilterOperator rawValue) + [InlineData(UnitWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(UnitWithProrationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(UnitWithProrationCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -38837,7 +46280,7 @@ public void Validation_Works(GroupedAllocationCompositePriceFilterOperator rawVa public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -38845,16 +46288,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(GroupedAllocationCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterOperator rawValue) + [InlineData(UnitWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(UnitWithProrationCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(UnitWithProrationCompositePriceFilterOperator 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); @@ -38864,23 +46307,23 @@ public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterOp 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 GroupedAllocationConversionRateConfigTest : TestBase +public class UnitWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() + UnitWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -38891,7 +46334,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() + UnitWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -38911,13 +46354,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() + UnitWithProrationConversionRateConfig 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 ); @@ -38928,7 +46371,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() + UnitWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -38943,7 +46386,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -38952,103 +46395,23 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedAllocationGroupedAllocationConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new GroupedAllocationGroupedAllocationConfig - { - 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 GroupedAllocationGroupedAllocationConfig - { - 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 GroupedAllocationGroupedAllocationConfig - { - 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 GroupedAllocationGroupedAllocationConfig - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }; - - model.Validate(); - } -} - -public class GroupedAllocationPriceTypeTest : TestBase +public class UnitWithProrationPriceTypeTest : TestBase { [Theory] - [InlineData(GroupedAllocationPriceType.UsagePrice)] - [InlineData(GroupedAllocationPriceType.FixedPrice)] - [InlineData(GroupedAllocationPriceType.CompositePrice)] - public void Validation_Works(GroupedAllocationPriceType rawValue) + [InlineData(UnitWithProrationPriceType.UsagePrice)] + [InlineData(UnitWithProrationPriceType.FixedPrice)] + [InlineData(UnitWithProrationPriceType.CompositePrice)] + public void Validation_Works(UnitWithProrationPriceType 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 ); @@ -39058,16 +46421,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedAllocationPriceType.UsagePrice)] - [InlineData(GroupedAllocationPriceType.FixedPrice)] - [InlineData(GroupedAllocationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(GroupedAllocationPriceType rawValue) + [InlineData(UnitWithProrationPriceType.UsagePrice)] + [InlineData(UnitWithProrationPriceType.FixedPrice)] + [InlineData(UnitWithProrationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(UnitWithProrationPriceType 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 ); @@ -39078,12 +46441,12 @@ public void SerializationRoundtrip_Works(GroupedAllocationPriceType 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 ); @@ -39092,30 +46455,181 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class BulkWithProrationTest : TestBase +public class UnitWithProrationUnitWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_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() + var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnitWithProrationUnitWithProrationConfig { 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 UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + + 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 +{ + [Fact] + public void FieldRoundtrip_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 = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -39144,6 +46658,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39164,6 +46679,13 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -39199,13 +46721,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -39215,27 +46743,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - BulkWithProrationBillingMode.InAdvance; - BulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ); - ApiEnum expectedCadence = - BulkWithProrationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedAllocationBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedAllocationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - BulkWithProrationConversionRateConfig expectedConversionRateConfig = + GroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -39260,6 +46782,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39280,6 +46803,13 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + GroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -39317,23 +46847,28 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - BulkWithProrationPriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedAllocationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); Assert.Equal(expectedBillingMode, model.BillingMode); - Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.NotNull(model.CompositePriceFilters); Assert.Equal(expectedCompositePriceFilters.Count, model.CompositePriceFilters.Count); @@ -39349,6 +46884,8 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedGroupedAllocationConfig, model.GroupedAllocationConfig); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -39368,30 +46905,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -39420,6 +46952,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39440,6 +46973,13 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -39475,17 +47015,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -39496,25 +47042,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -39543,6 +47083,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39563,6 +47104,13 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -39598,17 +47146,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -39621,27 +47175,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - BulkWithProrationBillingMode.InAdvance; - BulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ); - ApiEnum expectedCadence = - BulkWithProrationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedAllocationBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedAllocationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - BulkWithProrationConversionRateConfig expectedConversionRateConfig = + GroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -39666,6 +47214,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39686,6 +47235,13 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + GroupedAllocationGroupedAllocationConfig expectedGroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -39723,23 +47279,28 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_allocation"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - BulkWithProrationPriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedAllocationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); Assert.Equal(expectedBillingMode, deserialized.BillingMode); - Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.NotNull(deserialized.CompositePriceFilters); Assert.Equal(expectedCompositePriceFilters.Count, deserialized.CompositePriceFilters.Count); @@ -39755,6 +47316,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedGroupedAllocationConfig, deserialized.GroupedAllocationConfig); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -39777,30 +47340,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -39829,6 +47387,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39849,6 +47408,13 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -39884,13 +47450,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + 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", + }, }; model.Validate(); @@ -39899,25 +47471,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -39946,6 +47512,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39966,6 +47533,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -40001,36 +47575,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + PriceType = GroupedAllocationPriceType.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 BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -40059,6 +47629,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40079,6 +47650,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -40114,7 +47692,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + PriceType = GroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -40124,25 +47702,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -40171,6 +47743,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40191,6 +47764,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -40226,38 +47806,35 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + PriceType = GroupedAllocationPriceType.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 BulkWithProration + var model = new GroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -40286,6 +47863,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40306,6 +47884,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -40341,32 +47926,160 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + PriceType = GroupedAllocationPriceType.UsagePrice, 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 BulkWithProrationBillingModeTest : TestBase +public class GroupedAllocationBillingModeTest : TestBase { [Theory] - [InlineData(BulkWithProrationBillingMode.InAdvance)] - [InlineData(BulkWithProrationBillingMode.InArrear)] - public void Validation_Works(BulkWithProrationBillingMode rawValue) + [InlineData(GroupedAllocationBillingMode.InAdvance)] + [InlineData(GroupedAllocationBillingMode.InArrear)] + public void Validation_Works(GroupedAllocationBillingMode 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 ); @@ -40376,16 +48089,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(BulkWithProrationBillingMode.InAdvance)] - [InlineData(BulkWithProrationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(BulkWithProrationBillingMode rawValue) + [InlineData(GroupedAllocationBillingMode.InAdvance)] + [InlineData(GroupedAllocationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(GroupedAllocationBillingMode 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); @@ -40394,144 +48107,124 @@ public void SerializationRoundtrip_Works(BulkWithProrationBillingMode 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 BulkWithProrationBulkWithProrationConfigTest : TestBase +public class GroupedAllocationCadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [Theory] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.Custom)] + public void Validation_Works(GroupedAllocationCadence rawValue) { - var model = new BulkWithProrationBulkWithProrationConfig - { - 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]); - } + // 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 BulkWithProrationBulkWithProrationConfig - { - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(GroupedAllocationCadence.OneTime)] + [InlineData(GroupedAllocationCadence.Monthly)] + [InlineData(GroupedAllocationCadence.Quarterly)] + [InlineData(GroupedAllocationCadence.SemiAnnual)] + [InlineData(GroupedAllocationCadence.Annual)] + [InlineData(GroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedAllocationCadence rawValue) { - var model = new BulkWithProrationBulkWithProrationConfig - { - 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 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]); - } + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new BulkWithProrationBulkWithProrationConfig - { - 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 BulkWithProrationBulkWithProrationConfigTierTest : TestBase +public class GroupedAllocationCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithProrationBulkWithProrationConfigTier + var model = new GroupedAllocationCompositePriceFilter { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + ApiEnum expectedField = + GroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedAllocationCompositePriceFilterOperator.Includes; + List expectedValues = ["string"]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + 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 BulkWithProrationBulkWithProrationConfigTier + var model = new GroupedAllocationCompositePriceFilter { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -40542,281 +48235,104 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithProrationBulkWithProrationConfigTier + var model = new GroupedAllocationCompositePriceFilter { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + ApiEnum expectedField = + GroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedAllocationCompositePriceFilterOperator.Includes; + List expectedValues = ["string"]; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + 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 BulkWithProrationBulkWithProrationConfigTier + var model = new GroupedAllocationCompositePriceFilter { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new BulkWithProrationBulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + var model = new GroupedAllocationCompositePriceFilter + { + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + GroupedAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); } +} - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() +public class GroupedAllocationCompositePriceFilterFieldTest : TestBase +{ + [Theory] + [InlineData(GroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(GroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(GroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(GroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(GroupedAllocationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(GroupedAllocationCompositePriceFilterField rawValue) { - var model = new BulkWithProrationBulkWithProrationConfigTier { UnitAmount = "unit_amount" }; - - model.Validate(); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new BulkWithProrationBulkWithProrationConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new BulkWithProrationBulkWithProrationConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} - -public class BulkWithProrationCadenceTest : TestBase -{ - [Theory] - [InlineData(BulkWithProrationCadence.OneTime)] - [InlineData(BulkWithProrationCadence.Monthly)] - [InlineData(BulkWithProrationCadence.Quarterly)] - [InlineData(BulkWithProrationCadence.SemiAnnual)] - [InlineData(BulkWithProrationCadence.Annual)] - [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.OneTime)] - [InlineData(BulkWithProrationCadence.Monthly)] - [InlineData(BulkWithProrationCadence.Quarterly)] - [InlineData(BulkWithProrationCadence.SemiAnnual)] - [InlineData(BulkWithProrationCadence.Annual)] - [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 BulkWithProrationCompositePriceFilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new BulkWithProrationCompositePriceFilter - { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - ApiEnum expectedField = - BulkWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter - { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter - { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedField = - BulkWithProrationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter - { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - model.Validate(); - } -} - -public class BulkWithProrationCompositePriceFilterFieldTest : TestBase -{ - [Theory] - [InlineData(BulkWithProrationCompositePriceFilterField.PriceID)] - [InlineData(BulkWithProrationCompositePriceFilterField.ItemID)] - [InlineData(BulkWithProrationCompositePriceFilterField.PriceType)] - [InlineData(BulkWithProrationCompositePriceFilterField.Currency)] - [InlineData(BulkWithProrationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(BulkWithProrationCompositePriceFilterField rawValue) - { - // force 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()); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(BulkWithProrationCompositePriceFilterField.PriceID)] - [InlineData(BulkWithProrationCompositePriceFilterField.ItemID)] - [InlineData(BulkWithProrationCompositePriceFilterField.PriceType)] - [InlineData(BulkWithProrationCompositePriceFilterField.Currency)] - [InlineData(BulkWithProrationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterField rawValue) + [InlineData(GroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(GroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(GroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(GroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(GroupedAllocationCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterField 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); @@ -40826,26 +48342,26 @@ public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterFi 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 BulkWithProrationCompositePriceFilterOperatorTest : TestBase +public class GroupedAllocationCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(BulkWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(BulkWithProrationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(BulkWithProrationCompositePriceFilterOperator rawValue) + [InlineData(GroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(GroupedAllocationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(GroupedAllocationCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -40853,7 +48369,7 @@ public void Validation_Works(BulkWithProrationCompositePriceFilterOperator rawVa public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -40861,16 +48377,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(BulkWithProrationCompositePriceFilterOperator.Includes)] - [InlineData(BulkWithProrationCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterOperator rawValue) + [InlineData(GroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(GroupedAllocationCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(GroupedAllocationCompositePriceFilterOperator 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); @@ -40880,23 +48396,23 @@ public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterOp 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 BulkWithProrationConversionRateConfigTest : TestBase +public class GroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - BulkWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -40907,7 +48423,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - BulkWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() + GroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -40927,13 +48443,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - BulkWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedAllocationConversionRateConfig 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 ); @@ -40944,7 +48460,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - BulkWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() + GroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -40959,7 +48475,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -40968,23 +48484,118 @@ public void TieredSerializationRoundtripWorks() } } -public class BulkWithProrationPriceTypeTest : TestBase +public class GroupedAllocationGroupedAllocationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationGroupedAllocationConfig + { + 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 GroupedAllocationGroupedAllocationConfig + { + 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 GroupedAllocationGroupedAllocationConfig + { + 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 GroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + 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 { [Theory] - [InlineData(BulkWithProrationPriceType.UsagePrice)] - [InlineData(BulkWithProrationPriceType.FixedPrice)] - [InlineData(BulkWithProrationPriceType.CompositePrice)] - public void Validation_Works(BulkWithProrationPriceType rawValue) + [InlineData(GroupedAllocationPriceType.UsagePrice)] + [InlineData(GroupedAllocationPriceType.FixedPrice)] + [InlineData(GroupedAllocationPriceType.CompositePrice)] + public void Validation_Works(GroupedAllocationPriceType 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 ); @@ -40994,16 +48605,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(BulkWithProrationPriceType.UsagePrice)] - [InlineData(BulkWithProrationPriceType.FixedPrice)] - [InlineData(BulkWithProrationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(BulkWithProrationPriceType rawValue) + [InlineData(GroupedAllocationPriceType.UsagePrice)] + [InlineData(GroupedAllocationPriceType.FixedPrice)] + [InlineData(GroupedAllocationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(GroupedAllocationPriceType 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 ); @@ -41014,12 +48625,12 @@ public void SerializationRoundtrip_Works(BulkWithProrationPriceType 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 ); @@ -41028,24 +48639,125 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class GroupedWithProratedMinimumTest : TestBase +public class GroupedAllocationLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithProratedMinimum + 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] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -41074,6 +48786,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41094,12 +48807,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41135,13 +48843,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -41151,21 +48865,27 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedWithProratedMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithProratedMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + BulkWithProrationBillingMode.InAdvance; + BulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = + BulkWithProrationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedWithProratedMinimumConversionRateConfig expectedConversionRateConfig = + BulkWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -41190,6 +48910,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41210,13 +48931,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = - new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -41254,24 +48969,29 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_prorated_minimum" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithProratedMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + BulkWithProrationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); Assert.Equal(expectedBillingMode, model.BillingMode); + Assert.Equal(expectedBulkWithProrationConfig, model.BulkWithProrationConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.NotNull(model.CompositePriceFilters); Assert.Equal(expectedCompositePriceFilters.Count, model.CompositePriceFilters.Count); @@ -41287,10 +49007,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal( - expectedGroupedWithProratedMinimumConfig, - model.GroupedWithProratedMinimumConfig - ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -41310,24 +49027,31 @@ 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] public void SerializationRoundtrip_Works() { - var model = new GroupedWithProratedMinimum + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -41356,6 +49080,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41376,12 +49101,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41417,17 +49137,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -41438,19 +49164,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithProratedMinimum + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -41479,6 +49211,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41499,12 +49232,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41540,17 +49268,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -41563,21 +49297,27 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedWithProratedMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithProratedMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + BulkWithProrationBillingMode.InAdvance; + BulkWithProrationBulkWithProrationConfig expectedBulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ); + ApiEnum expectedCadence = + BulkWithProrationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedWithProratedMinimumConversionRateConfig expectedConversionRateConfig = + BulkWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -41602,6 +49342,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41622,13 +49363,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = - new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -41666,24 +49401,29 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_prorated_minimum" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithProratedMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + BulkWithProrationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); Assert.Equal(expectedBillingMode, deserialized.BillingMode); + Assert.Equal(expectedBulkWithProrationConfig, deserialized.BulkWithProrationConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.NotNull(deserialized.CompositePriceFilters); Assert.Equal(expectedCompositePriceFilters.Count, deserialized.CompositePriceFilters.Count); @@ -41699,10 +49439,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal( - expectedGroupedWithProratedMinimumConfig, - deserialized.GroupedWithProratedMinimumConfig - ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -41725,141 +49462,31 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new GroupedWithProratedMinimum + var model = new BulkWithProration { 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 = + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( [ - 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", - }, - }; - - 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, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -41888,6 +49515,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41908,12 +49536,132 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + AppliesToPriceIds = ["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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41949,30 +49697,38 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + PriceType = BulkWithProrationPriceType.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 + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -42001,6 +49757,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42021,12 +49778,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -42062,7 +49814,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + PriceType = BulkWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -42072,19 +49824,25 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithProratedMinimum + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -42113,6 +49871,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42133,12 +49892,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -42174,32 +49928,41 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + PriceType = BulkWithProrationPriceType.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 GroupedWithProratedMinimum + var model = new BulkWithProration { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -42228,6 +49991,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42248,12 +50012,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -42289,50 +50048,179 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + PriceType = BulkWithProrationPriceType.UsagePrice, 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 GroupedWithProratedMinimumBillingModeTest : TestBase +public class BulkWithProrationBillingModeTest : TestBase { [Theory] - [InlineData(GroupedWithProratedMinimumBillingMode.InAdvance)] - [InlineData(GroupedWithProratedMinimumBillingMode.InArrear)] - public void Validation_Works(GroupedWithProratedMinimumBillingMode rawValue) + [InlineData(BulkWithProrationBillingMode.InAdvance)] + [InlineData(BulkWithProrationBillingMode.InArrear)] + public void Validation_Works(BulkWithProrationBillingMode 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(GroupedWithProratedMinimumBillingMode.InAdvance)] - [InlineData(GroupedWithProratedMinimumBillingMode.InArrear)] - public void SerializationRoundtrip_Works(GroupedWithProratedMinimumBillingMode rawValue) + [InlineData(BulkWithProrationBillingMode.InAdvance)] + [InlineData(BulkWithProrationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(BulkWithProrationBillingMode 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); @@ -42341,122 +50229,5191 @@ public void SerializationRoundtrip_Works(GroupedWithProratedMinimumBillingMode r [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 GroupedWithProratedMinimumCadenceTest : TestBase +public class BulkWithProrationBulkWithProrationConfigTest : TestBase { - [Theory] - [InlineData(GroupedWithProratedMinimumCadence.OneTime)] - [InlineData(GroupedWithProratedMinimumCadence.Monthly)] - [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] - [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] - [InlineData(GroupedWithProratedMinimumCadence.Annual)] - [InlineData(GroupedWithProratedMinimumCadence.Custom)] - public void Validation_Works(GroupedWithProratedMinimumCadence 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 BulkWithProrationBulkWithProrationConfig + { + 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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new BulkWithProrationBulkWithProrationConfig + { + 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.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(GroupedWithProratedMinimumCadence.OneTime)] - [InlineData(GroupedWithProratedMinimumCadence.Monthly)] - [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] - [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] - [InlineData(GroupedWithProratedMinimumCadence.Annual)] - [InlineData(GroupedWithProratedMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithProratedMinimumCadence rawValue) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new BulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + List 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 InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new BulkWithProrationBulkWithProrationConfig + { + 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 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 GroupedWithProratedMinimumCompositePriceFilterTest : TestBase +public class BulkWithProrationBulkWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier + { + 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 BulkWithProrationBulkWithProrationConfigTier + { + 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 BulkWithProrationBulkWithProrationConfigTier + { + 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 BulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier + { + 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 BulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + 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 +{ + [Theory] + [InlineData(BulkWithProrationCadence.OneTime)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Annual)] + [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.OneTime)] + [InlineData(BulkWithProrationCadence.Monthly)] + [InlineData(BulkWithProrationCadence.Quarterly)] + [InlineData(BulkWithProrationCadence.SemiAnnual)] + [InlineData(BulkWithProrationCadence.Annual)] + [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 BulkWithProrationCompositePriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = + BulkWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = + BulkWithProrationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + BulkWithProrationCompositePriceFilterOperator.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 BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + 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 +{ + [Theory] + [InlineData(BulkWithProrationCompositePriceFilterField.PriceID)] + [InlineData(BulkWithProrationCompositePriceFilterField.ItemID)] + [InlineData(BulkWithProrationCompositePriceFilterField.PriceType)] + [InlineData(BulkWithProrationCompositePriceFilterField.Currency)] + [InlineData(BulkWithProrationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(BulkWithProrationCompositePriceFilterField rawValue) + { + // force 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(BulkWithProrationCompositePriceFilterField.PriceID)] + [InlineData(BulkWithProrationCompositePriceFilterField.ItemID)] + [InlineData(BulkWithProrationCompositePriceFilterField.PriceType)] + [InlineData(BulkWithProrationCompositePriceFilterField.Currency)] + [InlineData(BulkWithProrationCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterField rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class BulkWithProrationCompositePriceFilterOperatorTest : TestBase +{ + [Theory] + [InlineData(BulkWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(BulkWithProrationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(BulkWithProrationCompositePriceFilterOperator rawValue) + { + // force 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(BulkWithProrationCompositePriceFilterOperator.Includes)] + [InlineData(BulkWithProrationCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(BulkWithProrationCompositePriceFilterOperator rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class BulkWithProrationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + BulkWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + BulkWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithProrationConversionRateConfig 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() + { + BulkWithProrationConversionRateConfig 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 BulkWithProrationPriceTypeTest : TestBase +{ + [Theory] + [InlineData(BulkWithProrationPriceType.UsagePrice)] + [InlineData(BulkWithProrationPriceType.FixedPrice)] + [InlineData(BulkWithProrationPriceType.CompositePrice)] + public void Validation_Works(BulkWithProrationPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(BulkWithProrationPriceType.UsagePrice)] + [InlineData(BulkWithProrationPriceType.FixedPrice)] + [InlineData(BulkWithProrationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(BulkWithProrationPriceType rawValue) + { + // force 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 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] + public void FieldRoundtrip_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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + string expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = + GroupedWithProratedMinimumBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithProratedMinimumCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + GroupedWithProratedMinimumConversionRateConfig 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; + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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( + "grouped_with_prorated_minimum" + ); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + GroupedWithProratedMinimumPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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( + expectedGroupedWithProratedMinimumConfig, + model.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); + } + + [Fact] + public void SerializationRoundtrip_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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + string json = 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 + { + 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + 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 = + GroupedWithProratedMinimumBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithProratedMinimumCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + GroupedWithProratedMinimumConversionRateConfig 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; + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig expectedGroupedWithProratedMinimumConfig = + new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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( + "grouped_with_prorated_minimum" + ); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + GroupedWithProratedMinimumPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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( + expectedGroupedWithProratedMinimumConfig, + deserialized.GroupedWithProratedMinimumConfig + ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + 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 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + 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() + { + 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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() + { + 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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", + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +{ + [Theory] + [InlineData(GroupedWithProratedMinimumBillingMode.InAdvance)] + [InlineData(GroupedWithProratedMinimumBillingMode.InArrear)] + public void Validation_Works(GroupedWithProratedMinimumBillingMode rawValue) + { + // force 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(GroupedWithProratedMinimumBillingMode.InAdvance)] + [InlineData(GroupedWithProratedMinimumBillingMode.InArrear)] + public void SerializationRoundtrip_Works(GroupedWithProratedMinimumBillingMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithProratedMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCadence.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Annual)] + [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.OneTime)] + [InlineData(GroupedWithProratedMinimumCadence.Monthly)] + [InlineData(GroupedWithProratedMinimumCadence.Quarterly)] + [InlineData(GroupedWithProratedMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithProratedMinimumCadence.Annual)] + [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 GroupedWithProratedMinimumCompositePriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = + GroupedWithProratedMinimumCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithProratedMinimumCompositePriceFilterOperator.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 GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.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 GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = + GroupedWithProratedMinimumCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithProratedMinimumCompositePriceFilterOperator.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 GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + 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 +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.Currency)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(GroupedWithProratedMinimumCompositePriceFilterField rawValue) + { + // force 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(GroupedWithProratedMinimumCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.Currency)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + GroupedWithProratedMinimumCompositePriceFilterField rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithProratedMinimumCompositePriceFilterOperatorTest : TestBase +{ + [Theory] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes)] + public void Validation_Works(GroupedWithProratedMinimumCompositePriceFilterOperator rawValue) + { + // force 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(GroupedWithProratedMinimumCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + GroupedWithProratedMinimumCompositePriceFilterOperator rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithProratedMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithProratedMinimumConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithProratedMinimumConversionRateConfig 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() + { + GroupedWithProratedMinimumConversionRateConfig 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + 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 +{ + [Theory] + [InlineData(GroupedWithProratedMinimumPriceType.UsagePrice)] + [InlineData(GroupedWithProratedMinimumPriceType.FixedPrice)] + [InlineData(GroupedWithProratedMinimumPriceType.CompositePrice)] + public void Validation_Works(GroupedWithProratedMinimumPriceType rawValue) + { + // force 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(GroupedWithProratedMinimumPriceType.UsagePrice)] + [InlineData(GroupedWithProratedMinimumPriceType.FixedPrice)] + [InlineData(GroupedWithProratedMinimumPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(GroupedWithProratedMinimumPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +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] + public void FieldRoundtrip_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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + string expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = + GroupedWithMeteredMinimumBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithMeteredMinimumCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + GroupedWithMeteredMinimumConversionRateConfig 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; + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig 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 expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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( + "grouped_with_metered_minimum" + ); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + GroupedWithMeteredMinimumPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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( + expectedGroupedWithMeteredMinimumConfig, + model.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); + } + + [Fact] + public void SerializationRoundtrip_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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + string json = 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 + { + 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + 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 = + GroupedWithMeteredMinimumBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithMeteredMinimumCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + GroupedWithMeteredMinimumConversionRateConfig 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; + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig 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 expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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( + "grouped_with_metered_minimum" + ); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + GroupedWithMeteredMinimumPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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( + expectedGroupedWithMeteredMinimumConfig, + deserialized.GroupedWithMeteredMinimumConfig + ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + 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 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + 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"], + }, + ], + 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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() + { + 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumBillingMode.InAdvance)] + [InlineData(GroupedWithMeteredMinimumBillingMode.InArrear)] + public void Validation_Works(GroupedWithMeteredMinimumBillingMode rawValue) + { + // force 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(GroupedWithMeteredMinimumBillingMode.InAdvance)] + [InlineData(GroupedWithMeteredMinimumBillingMode.InArrear)] + public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumBillingMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithMeteredMinimumCadenceTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Annual)] + [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.OneTime)] + [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] + [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] + [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] + [InlineData(GroupedWithMeteredMinimumCadence.Annual)] + [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 GroupedWithMeteredMinimumCompositePriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = + GroupedWithMeteredMinimumCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithMeteredMinimumCompositePriceFilterOperator.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 GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.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 GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = + GroupedWithMeteredMinimumCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithMeteredMinimumCompositePriceFilterOperator.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 GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + 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 +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.Currency)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterField rawValue) + { + // force 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(GroupedWithMeteredMinimumCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.Currency)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + GroupedWithMeteredMinimumCompositePriceFilterField rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithMeteredMinimumCompositePriceFilterOperatorTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes)] + public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterOperator rawValue) + { + // force 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(GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + GroupedWithMeteredMinimumCompositePriceFilterOperator rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithMeteredMinimumConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMeteredMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + GroupedWithMeteredMinimumConversionRateConfig 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() + { + GroupedWithMeteredMinimumConversionRateConfig 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" }], + }; + + 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 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" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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" }], + }; + + 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 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" }], + }; + + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + 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 { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithProratedMinimumCompositePriceFilter + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], + PricingValue = "pricing_value", + UnitAmount = "unit_amount", }; - ApiEnum expectedField = - GroupedWithProratedMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithProratedMinimumCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; - 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]); - } + Assert.Equal(expectedPricingValue, model.PricingValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithProratedMinimumCompositePriceFilter + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], + PricingValue = "pricing_value", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -42467,148 +55424,91 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithProratedMinimumCompositePriceFilter + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], + PricingValue = "pricing_value", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - GroupedWithProratedMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithProratedMinimumCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; + string expectedPricingValue = "pricing_value"; + string expectedUnitAmount = "unit_amount"; - 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]); - } + Assert.Equal(expectedPricingValue, deserialized.PricingValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new GroupedWithProratedMinimumCompositePriceFilter + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], + PricingValue = "pricing_value", + UnitAmount = "unit_amount", }; model.Validate(); } -} - -public class GroupedWithProratedMinimumCompositePriceFilterFieldTest : TestBase -{ - [Theory] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.Currency)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(GroupedWithProratedMinimumCompositePriceFilterField rawValue) - { - // force 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(GroupedWithProratedMinimumCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.Currency)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works( - GroupedWithProratedMinimumCompositePriceFilterField 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class GroupedWithProratedMinimumCompositePriceFilterOperatorTest : TestBase +public class GroupedWithMeteredMinimumPriceTypeTest : TestBase { [Theory] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes)] - public void Validation_Works(GroupedWithProratedMinimumCompositePriceFilterOperator rawValue) + [InlineData(GroupedWithMeteredMinimumPriceType.UsagePrice)] + [InlineData(GroupedWithMeteredMinimumPriceType.FixedPrice)] + [InlineData(GroupedWithMeteredMinimumPriceType.CompositePrice)] + public void Validation_Works(GroupedWithMeteredMinimumPriceType 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works( - GroupedWithProratedMinimumCompositePriceFilterOperator rawValue - ) + [InlineData(GroupedWithMeteredMinimumPriceType.UsagePrice)] + [InlineData(GroupedWithMeteredMinimumPriceType.FixedPrice)] + [InlineData(GroupedWithMeteredMinimumPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumPriceType 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); @@ -42617,136 +55517,55 @@ GroupedWithProratedMinimumCompositePriceFilterOperator rawValue [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 GroupedWithProratedMinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - GroupedWithProratedMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - GroupedWithProratedMinimumConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - GroupedWithProratedMinimumConversionRateConfig 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() - { - GroupedWithProratedMinimumConversionRateConfig 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfigTest : TestBase +public class GroupedWithMeteredMinimumLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + var model = new GroupedWithMeteredMinimumLicenseType { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; - string expectedGroupingKey = "x"; - string expectedMinimum = "minimum"; - string expectedUnitRate = "unit_rate"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + Assert.Equal(expectedID, model.ID); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMinimum, model.Minimum); - Assert.Equal(expectedUnitRate, model.UnitRate); + Assert.Equal(expectedName, model.Name); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + var model = new GroupedWithMeteredMinimumLicenseType { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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); } @@ -42754,118 +55573,76 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + var model = new GroupedWithMeteredMinimumLicenseType { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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 expectedMinimum = "minimum"; - string expectedUnitRate = "unit_rate"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMinimum, deserialized.Minimum); - Assert.Equal(expectedUnitRate, deserialized.UnitRate); + Assert.Equal(expectedName, deserialized.Name); } [Fact] public void Validation_Works() { - var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + var model = new GroupedWithMeteredMinimumLicenseType { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; model.Validate(); } -} - -public class GroupedWithProratedMinimumPriceTypeTest : TestBase -{ - [Theory] - [InlineData(GroupedWithProratedMinimumPriceType.UsagePrice)] - [InlineData(GroupedWithProratedMinimumPriceType.FixedPrice)] - [InlineData(GroupedWithProratedMinimumPriceType.CompositePrice)] - public void Validation_Works(GroupedWithProratedMinimumPriceType rawValue) - { - // force 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(GroupedWithProratedMinimumPriceType.UsagePrice)] - [InlineData(GroupedWithProratedMinimumPriceType.FixedPrice)] - [InlineData(GroupedWithProratedMinimumPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(GroupedWithProratedMinimumPriceType 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 GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + GroupedWithMeteredMinimumLicenseType copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class GroupedWithMeteredMinimumTest : TestBase +public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -42894,6 +55671,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42914,21 +55692,14 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -42964,13 +55735,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -42980,21 +55757,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedWithMeteredMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithMeteredMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedWithMinMaxThresholdsBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedWithMeteredMinimumConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -43019,6 +55796,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43039,22 +55817,14 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig 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" }, - ], - }; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -43093,18 +55863,24 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_metered_minimum" + "grouped_with_min_max_thresholds" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithMeteredMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedWithMinMaxThresholdsPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -43126,9 +55902,10 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal( - expectedGroupedWithMeteredMinimumConfig, - model.GroupedWithMeteredMinimumConfig + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -43148,24 +55925,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -43194,6 +55972,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43214,21 +55993,14 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -43264,17 +56036,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -43285,19 +56063,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -43326,6 +56104,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43346,21 +56125,14 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -43396,17 +56168,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -43419,21 +56197,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedWithMeteredMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithMeteredMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedWithMinMaxThresholdsBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedWithMeteredMinimumConversionRateConfig expectedConversionRateConfig = + GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -43458,6 +56236,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43478,22 +56257,14 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig 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" }, - ], - }; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -43532,18 +56303,24 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_metered_minimum" + "grouped_with_min_max_thresholds" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithMeteredMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedWithMinMaxThresholdsPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -43565,9 +56342,10 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal( - expectedGroupedWithMeteredMinimumConfig, - deserialized.GroupedWithMeteredMinimumConfig + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -43590,24 +56368,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -43636,6 +56415,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43656,21 +56436,14 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -43706,13 +56479,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + 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", + }, }; model.Validate(); @@ -43721,19 +56500,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -43762,6 +56541,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43782,21 +56562,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -43832,30 +56605,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + PriceType = GroupedWithMinMaxThresholdsPriceType.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 + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -43884,6 +56659,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43904,21 +56680,129 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, ], - ScalingKey = "scaling_key", - UnitAmounts = + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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", + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -43954,29 +56838,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + PriceType = GroupedWithMinMaxThresholdsPriceType.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 GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -44005,6 +56895,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44025,21 +56916,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -44075,32 +56959,32 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, 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 GroupedWithMeteredMinimum + var model = new GroupedWithMinMaxThresholds { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -44129,6 +57013,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44149,21 +57034,14 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = 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" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -44199,25 +57077,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + PriceType = GroupedWithMinMaxThresholdsPriceType.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(); + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); } } -public class GroupedWithMeteredMinimumBillingModeTest : TestBase +public class GroupedWithMinMaxThresholdsBillingModeTest : TestBase { [Theory] - [InlineData(GroupedWithMeteredMinimumBillingMode.InAdvance)] - [InlineData(GroupedWithMeteredMinimumBillingMode.InArrear)] - public void Validation_Works(GroupedWithMeteredMinimumBillingMode rawValue) + [InlineData(GroupedWithMinMaxThresholdsBillingMode.InAdvance)] + [InlineData(GroupedWithMinMaxThresholdsBillingMode.InArrear)] + public void Validation_Works(GroupedWithMinMaxThresholdsBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -44225,7 +57114,7 @@ public void Validation_Works(GroupedWithMeteredMinimumBillingMode rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -44233,16 +57122,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMeteredMinimumBillingMode.InAdvance)] - [InlineData(GroupedWithMeteredMinimumBillingMode.InArrear)] - public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumBillingMode rawValue) + [InlineData(GroupedWithMinMaxThresholdsBillingMode.InAdvance)] + [InlineData(GroupedWithMinMaxThresholdsBillingMode.InArrear)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsBillingMode 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); @@ -44252,37 +57141,37 @@ public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumBillingMode ra 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 GroupedWithMeteredMinimumCadenceTest : TestBase +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] - [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] - [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] - [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] - [InlineData(GroupedWithMeteredMinimumCadence.Annual)] - [InlineData(GroupedWithMeteredMinimumCadence.Custom)] - public void Validation_Works(GroupedWithMeteredMinimumCadence rawValue) + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -44292,20 +57181,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMeteredMinimumCadence.OneTime)] - [InlineData(GroupedWithMeteredMinimumCadence.Monthly)] - [InlineData(GroupedWithMeteredMinimumCadence.Quarterly)] - [InlineData(GroupedWithMeteredMinimumCadence.SemiAnnual)] - [InlineData(GroupedWithMeteredMinimumCadence.Annual)] - [InlineData(GroupedWithMeteredMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumCadence rawValue) + [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -44314,35 +57203,35 @@ public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumCadence rawVal [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 GroupedWithMeteredMinimumCompositePriceFilterTest : TestBase +public class GroupedWithMinMaxThresholdsCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumCompositePriceFilter + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - GroupedWithMeteredMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -44357,16 +57246,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumCompositePriceFilter + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -44377,25 +57266,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMeteredMinimumCompositePriceFilter + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - GroupedWithMeteredMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -44410,29 +57299,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMeteredMinimumCompositePriceFilter + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 GroupedWithMeteredMinimumCompositePriceFilterFieldTest : TestBase +public class GroupedWithMinMaxThresholdsCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.Currency)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterField rawValue) + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(GroupedWithMinMaxThresholdsCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -44440,7 +57344,7 @@ public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterField public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -44448,21 +57352,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.Currency)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID)] public void SerializationRoundtrip_Works( - GroupedWithMeteredMinimumCompositePriceFilterField rawValue + GroupedWithMinMaxThresholdsCompositePriceFilterField 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); @@ -44472,26 +57376,26 @@ GroupedWithMeteredMinimumCompositePriceFilterField 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 GroupedWithMeteredMinimumCompositePriceFilterOperatorTest : TestBase +public class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes)] - public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterOperator rawValue) + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes)] + public void Validation_Works(GroupedWithMinMaxThresholdsCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -44499,7 +57403,7 @@ public void Validation_Works(GroupedWithMeteredMinimumCompositePriceFilterOperat public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -44507,18 +57411,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes)] + [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - GroupedWithMeteredMinimumCompositePriceFilterOperator rawValue + GroupedWithMinMaxThresholdsCompositePriceFilterOperator 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); @@ -44528,23 +57432,23 @@ GroupedWithMeteredMinimumCompositePriceFilterOperator 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 GroupedWithMeteredMinimumConversionRateConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMeteredMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -44555,34 +57459,35 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMeteredMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMeteredMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -44593,23 +57498,24 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMeteredMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -44618,75 +57524,46 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + var model = new GroupedWithMinMaxThresholdsConfig { 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" }], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; 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" }, - ]; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; 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]); - } + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + var model = new GroupedWithMinMaxThresholdsConfig { 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" }], + 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); } @@ -44694,109 +57571,155 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + var model = new GroupedWithMinMaxThresholdsConfig { 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" }], + 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 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" }, - ]; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; 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]); - } + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + var model = new GroupedWithMinMaxThresholdsConfig { 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" }], + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorTest : TestBase +public class GroupedWithMinMaxThresholdsPriceTypeTest : TestBase +{ + [Theory] + [InlineData(GroupedWithMinMaxThresholdsPriceType.UsagePrice)] + [InlineData(GroupedWithMinMaxThresholdsPriceType.FixedPrice)] + [InlineData(GroupedWithMinMaxThresholdsPriceType.CompositePrice)] + public void Validation_Works(GroupedWithMinMaxThresholdsPriceType rawValue) + { + // force 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(GroupedWithMinMaxThresholdsPriceType.UsagePrice)] + [InlineData(GroupedWithMinMaxThresholdsPriceType.FixedPrice)] + [InlineData(GroupedWithMinMaxThresholdsPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class GroupedWithMinMaxThresholdsLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + var model = new GroupedWithMinMaxThresholdsLicenseType { - ScalingFactor = "scaling_factor", - ScalingValue = "scaling_value", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; - string expectedScalingFactor = "scaling_factor"; - string expectedScalingValue = "scaling_value"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedScalingFactor, model.ScalingFactor); - Assert.Equal(expectedScalingValue, model.ScalingValue); + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + var model = new GroupedWithMinMaxThresholdsLicenseType { - ScalingFactor = "scaling_factor", - ScalingValue = "scaling_value", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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); } @@ -44804,190 +57727,524 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + var model = new GroupedWithMinMaxThresholdsLicenseType { - ScalingFactor = "scaling_factor", - ScalingValue = "scaling_value", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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 expectedScalingFactor = "scaling_factor"; - string expectedScalingValue = "scaling_value"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); - Assert.Equal(expectedScalingValue, deserialized.ScalingValue); + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); } [Fact] public void Validation_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + var model = new GroupedWithMinMaxThresholdsLicenseType { - ScalingFactor = "scaling_factor", - ScalingValue = "scaling_value", + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountTest : TestBase +public class MatrixWithDisplayNameTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + string expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = + MatrixWithDisplayNameBillingMode.InAdvance; + ApiEnum expectedCadence = + MatrixWithDisplayNameCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + MatrixWithDisplayNameConversionRateConfig 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; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + 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() { - PricingValue = "pricing_value", - UnitAmount = "unit_amount", + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + string expectedMinimumAmount = "minimum_amount"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_display_name" + ); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = + MatrixWithDisplayNamePriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { - PricingValue = "pricing_value", - UnitAmount = "unit_amount", + 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + MatrixWithDisplayNameLicenseType expectedLicenseType = new() { - PricingValue = "pricing_value", - UnitAmount = "unit_amount", + 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 expectedPricingValue = "pricing_value"; - string expectedUnitAmount = "unit_amount"; + 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(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedItem, model.Item); + Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); + 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(expectedPricingValue, deserialized.PricingValue); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { - var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + var model = new MatrixWithDisplayName { - PricingValue = "pricing_value", - UnitAmount = "unit_amount", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, }; - model.Validate(); - } -} - -public class GroupedWithMeteredMinimumPriceTypeTest : TestBase -{ - [Theory] - [InlineData(GroupedWithMeteredMinimumPriceType.UsagePrice)] - [InlineData(GroupedWithMeteredMinimumPriceType.FixedPrice)] - [InlineData(GroupedWithMeteredMinimumPriceType.CompositePrice)] - public void Validation_Works(GroupedWithMeteredMinimumPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(GroupedWithMeteredMinimumPriceType.UsagePrice)] - [InlineData(GroupedWithMeteredMinimumPriceType.FixedPrice)] - [InlineData(GroupedWithMeteredMinimumPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(GroupedWithMeteredMinimumPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(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"), + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } -} -public class GroupedWithMinMaxThresholdsTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45016,6 +58273,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45036,15 +58294,22 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -45078,15 +58343,28 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + 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", + }, }; + 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() @@ -45094,21 +58372,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedWithMinMaxThresholdsBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MatrixWithDisplayNameBillingMode.InAdvance; + ApiEnum expectedCadence = + MatrixWithDisplayNameCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MatrixWithDisplayNameConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -45133,6 +58411,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45153,19 +58432,26 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -45198,79 +58484,87 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_display_name" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithMinMaxThresholdsPriceType.UsagePrice; + ApiEnum expectedPriceType = + MatrixWithDisplayNamePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); - 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); + 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], model.CompositePriceFilters[i]); + Assert.Equal(expectedCompositePriceFilters[i], deserialized.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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); - 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); + 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(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedItem, deserialized.Item); + Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); + Assert.Equal(expectedMaximum, deserialized.Maximum); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, model.Metadata[item.Key]); + Assert.Equal(value, deserialized.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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + 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 SerializationRoundtrip_Works() + public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45299,6 +58593,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45319,15 +58614,22 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -45361,40 +58663,40 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + 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", + }, }; - 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 GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45423,6 +58725,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45443,15 +58746,22 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -45485,209 +58795,32 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + PriceType = MatrixWithDisplayNamePriceType.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 = - GroupedWithMinMaxThresholdsBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig 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; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - 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( - "grouped_with_min_max_thresholds" - ); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedWithMinMaxThresholdsPriceType.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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); - 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.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 Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45716,6 +58849,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45736,15 +58870,22 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -45778,34 +58919,29 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + PriceType = MatrixWithDisplayNamePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45834,6 +58970,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45854,15 +58991,22 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -45896,30 +59040,35 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + PriceType = MatrixWithDisplayNamePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + + DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -45948,6 +59097,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45968,15 +59118,22 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -46010,29 +59167,32 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + PriceType = MatrixWithDisplayNamePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + + DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void CopyConstructor_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayName { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -46061,6 +59221,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46081,15 +59242,22 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -46123,141 +59291,266 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + 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 +{ + [Theory] + [InlineData(MatrixWithDisplayNameBillingMode.InAdvance)] + [InlineData(MatrixWithDisplayNameBillingMode.InArrear)] + public void Validation_Works(MatrixWithDisplayNameBillingMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(MatrixWithDisplayNameBillingMode.InAdvance)] + [InlineData(MatrixWithDisplayNameBillingMode.InArrear)] + public void SerializationRoundtrip_Works(MatrixWithDisplayNameBillingMode rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(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 MatrixWithDisplayNameCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithDisplayNameCadence.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Annual)] + [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.OneTime)] + [InlineData(MatrixWithDisplayNameCadence.Monthly)] + [InlineData(MatrixWithDisplayNameCadence.Quarterly)] + [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] + [InlineData(MatrixWithDisplayNameCadence.Annual)] + [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 MatrixWithDisplayNameCompositePriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameCompositePriceFilter + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = + MatrixWithDisplayNameCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MatrixWithDisplayNameCompositePriceFilterOperator.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]); + } + } - DimensionalPriceConfiguration = null, + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameCompositePriceFilter + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], }; - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithDisplayNameCompositePriceFilter { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }; - DimensionalPriceConfiguration = null, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = + MatrixWithDisplayNameCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MatrixWithDisplayNameCompositePriceFilterOperator.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 MatrixWithDisplayNameCompositePriceFilter + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], }; 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 GroupedWithMinMaxThresholdsBillingModeTest : TestBase +public class MatrixWithDisplayNameCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsBillingMode.InAdvance)] - [InlineData(GroupedWithMinMaxThresholdsBillingMode.InArrear)] - public void Validation_Works(GroupedWithMinMaxThresholdsBillingMode rawValue) + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceID)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.ItemID)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceType)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.Currency)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -46265,7 +59558,7 @@ public void Validation_Works(GroupedWithMinMaxThresholdsBillingMode rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -46273,16 +59566,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedWithMinMaxThresholdsBillingMode.InAdvance)] - [InlineData(GroupedWithMinMaxThresholdsBillingMode.InArrear)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsBillingMode rawValue) + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceID)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.ItemID)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceType)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.Currency)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + MatrixWithDisplayNameCompositePriceFilterField 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); @@ -46292,60 +59590,53 @@ public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsBillingMode 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 GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class MatrixWithDisplayNameCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Includes)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Excludes)] + public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterOperator 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.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Includes)] + [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + MatrixWithDisplayNameCompositePriceFilterOperator 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); @@ -46354,59 +59645,281 @@ 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 GroupedWithMinMaxThresholdsCompositePriceFilterTest : TestBase +public class MatrixWithDisplayNameConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithDisplayNameConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithDisplayNameConversionRateConfig 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() + { + MatrixWithDisplayNameConversionRateConfig 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 MatrixWithDisplayNameMatrixWithDisplayNameConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], }; - ApiEnum expectedField = - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; + string expectedDimension = "dimension"; + List expectedUnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ]; - 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(expectedDimension, model.Dimension); + Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); + for (int i = 0; i < expectedUnitAmounts.Count; i++) { - Assert.Equal(expectedValues[i], model.Values[i]); + Assert.Equal(expectedUnitAmounts[i], model.UnitAmounts[i]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + { + 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 MatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + 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 MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -46417,148 +59930,96 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; + string expectedDimensionValue = "dimension_value"; + string expectedDisplayName = "display_name"; + string expectedUnitAmount = "unit_amount"; - 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]); - } + Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); + Assert.Equal(expectedDisplayName, deserialized.DisplayName); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }; model.Validate(); } -} - -public class GroupedWithMinMaxThresholdsCompositePriceFilterFieldTest : TestBase -{ - [Theory] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(GroupedWithMinMaxThresholdsCompositePriceFilterField rawValue) - { - // force 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(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works( - GroupedWithMinMaxThresholdsCompositePriceFilterField 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 MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorTest : TestBase +public class MatrixWithDisplayNamePriceTypeTest : TestBase { [Theory] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes)] - public void Validation_Works(GroupedWithMinMaxThresholdsCompositePriceFilterOperator rawValue) + [InlineData(MatrixWithDisplayNamePriceType.UsagePrice)] + [InlineData(MatrixWithDisplayNamePriceType.FixedPrice)] + [InlineData(MatrixWithDisplayNamePriceType.CompositePrice)] + public void Validation_Works(MatrixWithDisplayNamePriceType 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes)] - [InlineData(GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works( - GroupedWithMinMaxThresholdsCompositePriceFilterOperator rawValue - ) + [InlineData(MatrixWithDisplayNamePriceType.UsagePrice)] + [InlineData(MatrixWithDisplayNamePriceType.FixedPrice)] + [InlineData(MatrixWithDisplayNamePriceType.CompositePrice)] + public void SerializationRoundtrip_Works(MatrixWithDisplayNamePriceType 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); @@ -46567,136 +60028,52 @@ GroupedWithMinMaxThresholdsCompositePriceFilterOperator rawValue [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class GroupedWithMinMaxThresholdsConfigTest : TestBase +public class MatrixWithDisplayNameLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithDisplayNameLicenseType { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + Assert.Equal(expectedID, model.ID); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedName, model.Name); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithDisplayNameLicenseType { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -46707,121 +60084,76 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithDisplayNameLicenseType { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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 expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedName, deserialized.Name); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MatrixWithDisplayNameLicenseType { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; model.Validate(); } -} - -public class GroupedWithMinMaxThresholdsPriceTypeTest : TestBase -{ - [Theory] - [InlineData(GroupedWithMinMaxThresholdsPriceType.UsagePrice)] - [InlineData(GroupedWithMinMaxThresholdsPriceType.FixedPrice)] - [InlineData(GroupedWithMinMaxThresholdsPriceType.CompositePrice)] - public void Validation_Works(GroupedWithMinMaxThresholdsPriceType rawValue) - { - // force 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(GroupedWithMinMaxThresholdsPriceType.UsagePrice)] - [InlineData(GroupedWithMinMaxThresholdsPriceType.FixedPrice)] - [InlineData(GroupedWithMinMaxThresholdsPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsPriceType 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 MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + MatrixWithDisplayNameLicenseType copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class MatrixWithDisplayNameTest : TestBase +public class GroupedTieredPackageTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -46850,6 +60182,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46870,21 +60203,19 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -46918,13 +60249,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -46934,21 +60271,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - MatrixWithDisplayNameBillingMode.InAdvance; - ApiEnum expectedCadence = - MatrixWithDisplayNameCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedTieredPackageBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedTieredPackageCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - MatrixWithDisplayNameConversionRateConfig expectedConversionRateConfig = + GroupedTieredPackageConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -46973,6 +60310,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -46993,25 +60331,23 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + GroupedTieredPackageGroupedTieredPackageConfig 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 expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - MatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -47043,19 +60379,23 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "matrix_with_display_name" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - MatrixWithDisplayNamePriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedTieredPackagePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -47076,9 +60416,10 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); - Assert.Equal(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); Assert.Equal(expectedMaximum, model.Maximum); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); @@ -47096,24 +60437,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47142,6 +60484,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47162,21 +60505,19 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -47210,17 +60551,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -47231,19 +60578,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47272,6 +60619,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47292,21 +60640,19 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -47340,17 +60686,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -47363,21 +60715,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - MatrixWithDisplayNameBillingMode.InAdvance; - ApiEnum expectedCadence = - MatrixWithDisplayNameCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + GroupedTieredPackageBillingMode.InAdvance; + ApiEnum expectedCadence = + GroupedTieredPackageCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - MatrixWithDisplayNameConversionRateConfig expectedConversionRateConfig = + GroupedTieredPackageConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -47402,6 +60754,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -47422,25 +60775,23 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + GroupedTieredPackageGroupedTieredPackageConfig 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 expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - MatrixWithDisplayNameMatrixWithDisplayNameConfig expectedMatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -47472,19 +60823,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "matrix_with_display_name" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - MatrixWithDisplayNamePriceType.UsagePrice; + ApiEnum expectedPriceType = + GroupedTieredPackagePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -47505,9 +60860,10 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); - Assert.Equal(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); Assert.Equal(expectedMaximum, deserialized.Maximum); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); @@ -47528,24 +60884,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47574,6 +60931,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47594,21 +60952,19 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -47642,13 +60998,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + 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", + }, }; model.Validate(); @@ -47657,19 +61019,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47698,6 +61060,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47718,21 +61081,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -47766,30 +61127,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47818,6 +61181,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47838,21 +61202,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -47886,7 +61248,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -47896,19 +61258,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -47937,6 +61299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47957,21 +61320,143 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + Maximum = new() { - Dimension = "dimension", - UnitAmounts = + AppliesToPriceIds = ["string"], + Filters = [ new() { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + 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 = 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 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" }, + ], + }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -48005,32 +61490,32 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.UsagePrice, 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 MatrixWithDisplayName + var model = new GroupedTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -48059,6 +61544,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48079,21 +61565,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() + GroupedTieredPackageConfig = new() { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -48127,32 +61611,43 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.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(); + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); } } -public class MatrixWithDisplayNameBillingModeTest : TestBase +public class GroupedTieredPackageBillingModeTest : TestBase { [Theory] - [InlineData(MatrixWithDisplayNameBillingMode.InAdvance)] - [InlineData(MatrixWithDisplayNameBillingMode.InArrear)] - public void Validation_Works(MatrixWithDisplayNameBillingMode rawValue) + [InlineData(GroupedTieredPackageBillingMode.InAdvance)] + [InlineData(GroupedTieredPackageBillingMode.InArrear)] + public void Validation_Works(GroupedTieredPackageBillingMode 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 ); @@ -48162,16 +61657,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MatrixWithDisplayNameBillingMode.InAdvance)] - [InlineData(MatrixWithDisplayNameBillingMode.InArrear)] - public void SerializationRoundtrip_Works(MatrixWithDisplayNameBillingMode rawValue) + [InlineData(GroupedTieredPackageBillingMode.InAdvance)] + [InlineData(GroupedTieredPackageBillingMode.InArrear)] + public void SerializationRoundtrip_Works(GroupedTieredPackageBillingMode 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); @@ -48180,39 +61675,39 @@ public void SerializationRoundtrip_Works(MatrixWithDisplayNameBillingMode rawVal [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 MatrixWithDisplayNameCadenceTest : TestBase +public class GroupedTieredPackageCadenceTest : TestBase { [Theory] - [InlineData(MatrixWithDisplayNameCadence.OneTime)] - [InlineData(MatrixWithDisplayNameCadence.Monthly)] - [InlineData(MatrixWithDisplayNameCadence.Quarterly)] - [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] - [InlineData(MatrixWithDisplayNameCadence.Annual)] - [InlineData(MatrixWithDisplayNameCadence.Custom)] - public void Validation_Works(MatrixWithDisplayNameCadence rawValue) + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void Validation_Works(GroupedTieredPackageCadence 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 ); @@ -48222,21 +61717,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MatrixWithDisplayNameCadence.OneTime)] - [InlineData(MatrixWithDisplayNameCadence.Monthly)] - [InlineData(MatrixWithDisplayNameCadence.Quarterly)] - [InlineData(MatrixWithDisplayNameCadence.SemiAnnual)] - [InlineData(MatrixWithDisplayNameCadence.Annual)] - [InlineData(MatrixWithDisplayNameCadence.Custom)] - public void SerializationRoundtrip_Works(MatrixWithDisplayNameCadence rawValue) + [InlineData(GroupedTieredPackageCadence.OneTime)] + [InlineData(GroupedTieredPackageCadence.Monthly)] + [InlineData(GroupedTieredPackageCadence.Quarterly)] + [InlineData(GroupedTieredPackageCadence.SemiAnnual)] + [InlineData(GroupedTieredPackageCadence.Annual)] + [InlineData(GroupedTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(GroupedTieredPackageCadence 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); } @@ -48244,35 +61740,36 @@ public void SerializationRoundtrip_Works(MatrixWithDisplayNameCadence 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 - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class MatrixWithDisplayNameCompositePriceFilterTest : TestBase +public class GroupedTieredPackageCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MatrixWithDisplayNameCompositePriceFilter + var model = new GroupedTieredPackageCompositePriceFilter { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - MatrixWithDisplayNameCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - MatrixWithDisplayNameCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + GroupedTieredPackageCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedTieredPackageCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -48287,15 +61784,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new MatrixWithDisplayNameCompositePriceFilter + var model = new GroupedTieredPackageCompositePriceFilter { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -48306,24 +61803,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MatrixWithDisplayNameCompositePriceFilter + var model = new GroupedTieredPackageCompositePriceFilter { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - MatrixWithDisplayNameCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - MatrixWithDisplayNameCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + GroupedTieredPackageCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + GroupedTieredPackageCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -48338,29 +61835,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new MatrixWithDisplayNameCompositePriceFilter + var model = new GroupedTieredPackageCompositePriceFilter { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 MatrixWithDisplayNameCompositePriceFilterFieldTest : TestBase +public class GroupedTieredPackageCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceID)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.ItemID)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceType)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.Currency)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterField rawValue) + [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceID)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.ItemID)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceType)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.Currency)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(GroupedTieredPackageCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -48368,7 +61880,7 @@ public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterField rawV public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -48376,21 +61888,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceID)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.ItemID)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PriceType)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.Currency)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works( - MatrixWithDisplayNameCompositePriceFilterField rawValue - ) + [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceID)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.ItemID)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceType)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.Currency)] + [InlineData(GroupedTieredPackageCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(GroupedTieredPackageCompositePriceFilterField 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); @@ -48400,26 +61910,26 @@ MatrixWithDisplayNameCompositePriceFilterField 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 MatrixWithDisplayNameCompositePriceFilterOperatorTest : TestBase +public class GroupedTieredPackageCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Includes)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Excludes)] - public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterOperator rawValue) + [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Includes)] + [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Excludes)] + public void Validation_Works(GroupedTieredPackageCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -48427,7 +61937,7 @@ public void Validation_Works(MatrixWithDisplayNameCompositePriceFilterOperator r public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -48435,18 +61945,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Includes)] - [InlineData(MatrixWithDisplayNameCompositePriceFilterOperator.Excludes)] + [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Includes)] + [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - MatrixWithDisplayNameCompositePriceFilterOperator rawValue + GroupedTieredPackageCompositePriceFilterOperator 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); @@ -48456,23 +61966,23 @@ MatrixWithDisplayNameCompositePriceFilterOperator 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 MatrixWithDisplayNameConversionRateConfigTest : TestBase +public class GroupedTieredPackageConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MatrixWithDisplayNameConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -48483,7 +61993,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MatrixWithDisplayNameConversionRateConfig value = new SharedTieredConversionRateConfig() + GroupedTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -48503,13 +62013,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MatrixWithDisplayNameConversionRateConfig value = new SharedUnitConversionRateConfig() + GroupedTieredPackageConversionRateConfig 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 ); @@ -48520,7 +62030,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MatrixWithDisplayNameConversionRateConfig value = new SharedTieredConversionRateConfig() + GroupedTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -48535,7 +62045,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -48544,64 +62054,56 @@ public void TieredSerializationRoundtripWorks() } } -public class MatrixWithDisplayNameMatrixWithDisplayNameConfigTest : TestBase +public class GroupedTieredPackageGroupedTieredPackageConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + var model = new GroupedTieredPackageGroupedTieredPackageConfig { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }; - string expectedDimension = "dimension"; - List expectedUnitAmounts = + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ]; - Assert.Equal(expectedDimension, model.Dimension); - Assert.Equal(expectedUnitAmounts.Count, model.UnitAmounts.Count); - for (int i = 0; i < expectedUnitAmounts.Count; i++) + 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(expectedUnitAmounts[i], model.UnitAmounts[i]); + Assert.Equal(expectedTiers[i], model.Tiers[i]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + var model = new GroupedTieredPackageGroupedTieredPackageConfig { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -48612,102 +62114,109 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + var model = new GroupedTieredPackageGroupedTieredPackageConfig { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedDimension = "dimension"; - List expectedUnitAmounts = + string expectedGroupingKey = "x"; + string expectedPackageSize = "package_size"; + List expectedTiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ]; - Assert.Equal(expectedDimension, deserialized.Dimension); - Assert.Equal(expectedUnitAmounts.Count, deserialized.UnitAmounts.Count); - for (int i = 0; i < expectedUnitAmounts.Count; i++) + 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(expectedUnitAmounts[i], deserialized.UnitAmounts[i]); + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); } } [Fact] public void Validation_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + var model = new GroupedTieredPackageGroupedTieredPackageConfig { - Dimension = "dimension", - UnitAmounts = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + 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 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 MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountTest : TestBase +public class GroupedTieredPackageGroupedTieredPackageConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }; - string expectedDimensionValue = "dimension_value"; - string expectedDisplayName = "display_name"; - string expectedUnitAmount = "unit_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedDimensionValue, model.DimensionValue); - Assert.Equal(expectedDisplayName, model.DisplayName); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedPerUnit, model.PerUnit); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -48718,61 +62227,71 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedDimensionValue = "dimension_value"; - string expectedDisplayName = "display_name"; - string expectedUnitAmount = "unit_amount"; + string expectedPerUnit = "per_unit"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedDimensionValue, deserialized.DimensionValue); - Assert.Equal(expectedDisplayName, deserialized.DisplayName); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedPerUnit, deserialized.PerUnit); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }; 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 MatrixWithDisplayNamePriceTypeTest : TestBase +public class GroupedTieredPackagePriceTypeTest : TestBase { [Theory] - [InlineData(MatrixWithDisplayNamePriceType.UsagePrice)] - [InlineData(MatrixWithDisplayNamePriceType.FixedPrice)] - [InlineData(MatrixWithDisplayNamePriceType.CompositePrice)] - public void Validation_Works(MatrixWithDisplayNamePriceType rawValue) + [InlineData(GroupedTieredPackagePriceType.UsagePrice)] + [InlineData(GroupedTieredPackagePriceType.FixedPrice)] + [InlineData(GroupedTieredPackagePriceType.CompositePrice)] + public void Validation_Works(GroupedTieredPackagePriceType 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 ); @@ -48782,17 +62301,17 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MatrixWithDisplayNamePriceType.UsagePrice)] - [InlineData(MatrixWithDisplayNamePriceType.FixedPrice)] - [InlineData(MatrixWithDisplayNamePriceType.CompositePrice)] - public void SerializationRoundtrip_Works(MatrixWithDisplayNamePriceType rawValue) + [InlineData(GroupedTieredPackagePriceType.UsagePrice)] + [InlineData(GroupedTieredPackagePriceType.FixedPrice)] + [InlineData(GroupedTieredPackagePriceType.CompositePrice)] + public void SerializationRoundtrip_Works(GroupedTieredPackagePriceType 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); @@ -48801,37 +62320,132 @@ public void SerializationRoundtrip_Works(MatrixWithDisplayNamePriceType 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 GroupedTieredPackageTest : TestBase +public class GroupedTieredPackageLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedTieredPackage + 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] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -48860,6 +62474,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48880,18 +62495,19 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -48925,13 +62541,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -48941,21 +62563,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedTieredPackageBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedTieredPackageCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MaxGroupTieredPackageBillingMode.InAdvance; + ApiEnum expectedCadence = + MaxGroupTieredPackageCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedTieredPackageConversionRateConfig expectedConversionRateConfig = + MaxGroupTieredPackageConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -48980,6 +62602,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49000,22 +62623,23 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }; - BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ItemSlim expectedItem = new() { ID = "id", Name = "name" }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -49047,17 +62671,25 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedTieredPackagePriceType.UsagePrice; + ApiEnum expectedPriceType = + MaxGroupTieredPackagePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -49078,9 +62710,10 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedGroupedTieredPackageConfig, model.GroupedTieredPackageConfig); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); + Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); Assert.Equal(expectedMaximum, model.Maximum); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); @@ -49098,24 +62731,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49144,6 +62778,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49164,18 +62799,19 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49209,17 +62845,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -49230,19 +62872,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49271,6 +62913,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49291,18 +62934,19 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49336,17 +62980,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -49359,21 +63009,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - GroupedTieredPackageBillingMode.InAdvance; - ApiEnum expectedCadence = - GroupedTieredPackageCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MaxGroupTieredPackageBillingMode.InAdvance; + ApiEnum expectedCadence = + MaxGroupTieredPackageCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - GroupedTieredPackageConversionRateConfig expectedConversionRateConfig = + MaxGroupTieredPackageConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -49398,6 +63048,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49418,22 +63069,23 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; - GroupedTieredPackageGroupedTieredPackageConfig expectedGroupedTieredPackageConfig = new() + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ItemSlim expectedItem = new() { ID = "id", Name = "name" }; + MaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }; - BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ItemSlim expectedItem = new() { ID = "id", Name = "name" }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -49465,17 +63117,25 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "max_group_tiered_package" + ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - GroupedTieredPackagePriceType.UsagePrice; + ApiEnum expectedPriceType = + MaxGroupTieredPackagePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -49496,9 +63156,10 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedGroupedTieredPackageConfig, deserialized.GroupedTieredPackageConfig); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); + Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); Assert.Equal(expectedMaximum, deserialized.Maximum); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); @@ -49519,24 +63180,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49565,6 +63227,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49585,18 +63248,19 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49630,13 +63294,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + 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", + }, }; model.Validate(); @@ -49645,19 +63315,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49686,6 +63356,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49706,18 +63377,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49751,30 +63423,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.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 GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49803,6 +63477,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49823,18 +63498,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49868,7 +63544,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -49878,19 +63554,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -49919,6 +63595,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49939,18 +63616,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -49984,32 +63662,35 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.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 GroupedTieredPackage + var model = new MaxGroupTieredPackage { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -50038,6 +63719,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50058,18 +63740,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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"], @@ -50103,32 +63786,164 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.UsagePrice, 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 GroupedTieredPackageBillingModeTest : TestBase +public class MaxGroupTieredPackageBillingModeTest : TestBase { [Theory] - [InlineData(GroupedTieredPackageBillingMode.InAdvance)] - [InlineData(GroupedTieredPackageBillingMode.InArrear)] - public void Validation_Works(GroupedTieredPackageBillingMode rawValue) + [InlineData(MaxGroupTieredPackageBillingMode.InAdvance)] + [InlineData(MaxGroupTieredPackageBillingMode.InArrear)] + public void Validation_Works(MaxGroupTieredPackageBillingMode 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 ); @@ -50138,16 +63953,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedTieredPackageBillingMode.InAdvance)] - [InlineData(GroupedTieredPackageBillingMode.InArrear)] - public void SerializationRoundtrip_Works(GroupedTieredPackageBillingMode rawValue) + [InlineData(MaxGroupTieredPackageBillingMode.InAdvance)] + [InlineData(MaxGroupTieredPackageBillingMode.InArrear)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackageBillingMode 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); @@ -50156,39 +63971,39 @@ public void SerializationRoundtrip_Works(GroupedTieredPackageBillingMode rawValu [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 GroupedTieredPackageCadenceTest : TestBase +public class MaxGroupTieredPackageCadenceTest : TestBase { [Theory] - [InlineData(GroupedTieredPackageCadence.OneTime)] - [InlineData(GroupedTieredPackageCadence.Monthly)] - [InlineData(GroupedTieredPackageCadence.Quarterly)] - [InlineData(GroupedTieredPackageCadence.SemiAnnual)] - [InlineData(GroupedTieredPackageCadence.Annual)] - [InlineData(GroupedTieredPackageCadence.Custom)] - public void Validation_Works(GroupedTieredPackageCadence rawValue) + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void Validation_Works(MaxGroupTieredPackageCadence 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 ); @@ -50198,22 +64013,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedTieredPackageCadence.OneTime)] - [InlineData(GroupedTieredPackageCadence.Monthly)] - [InlineData(GroupedTieredPackageCadence.Quarterly)] - [InlineData(GroupedTieredPackageCadence.SemiAnnual)] - [InlineData(GroupedTieredPackageCadence.Annual)] - [InlineData(GroupedTieredPackageCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedTieredPackageCadence rawValue) + [InlineData(MaxGroupTieredPackageCadence.OneTime)] + [InlineData(MaxGroupTieredPackageCadence.Monthly)] + [InlineData(MaxGroupTieredPackageCadence.Quarterly)] + [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] + [InlineData(MaxGroupTieredPackageCadence.Annual)] + [InlineData(MaxGroupTieredPackageCadence.Custom)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence 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); } @@ -50221,36 +64035,35 @@ public void SerializationRoundtrip_Works(GroupedTieredPackageCadence 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 GroupedTieredPackageCompositePriceFilterTest : TestBase +public class MaxGroupTieredPackageCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedTieredPackageCompositePriceFilter + var model = new MaxGroupTieredPackageCompositePriceFilter { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - GroupedTieredPackageCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedTieredPackageCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MaxGroupTieredPackageCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MaxGroupTieredPackageCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -50265,15 +64078,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedTieredPackageCompositePriceFilter + var model = new MaxGroupTieredPackageCompositePriceFilter { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -50284,24 +64097,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedTieredPackageCompositePriceFilter + var model = new MaxGroupTieredPackageCompositePriceFilter { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - GroupedTieredPackageCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - GroupedTieredPackageCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MaxGroupTieredPackageCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MaxGroupTieredPackageCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -50316,29 +64129,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedTieredPackageCompositePriceFilter + var model = new MaxGroupTieredPackageCompositePriceFilter { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 GroupedTieredPackageCompositePriceFilterFieldTest : TestBase +public class MaxGroupTieredPackageCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceID)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.ItemID)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceType)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.Currency)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(GroupedTieredPackageCompositePriceFilterField rawValue) + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceID)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.ItemID)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceType)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.Currency)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -50346,7 +64174,7 @@ public void Validation_Works(GroupedTieredPackageCompositePriceFilterField rawVa public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -50354,19 +64182,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceID)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.ItemID)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PriceType)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.Currency)] - [InlineData(GroupedTieredPackageCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(GroupedTieredPackageCompositePriceFilterField rawValue) + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceID)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.ItemID)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceType)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.Currency)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + MaxGroupTieredPackageCompositePriceFilterField 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); @@ -50376,26 +64206,26 @@ public void SerializationRoundtrip_Works(GroupedTieredPackageCompositePriceFilte 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 GroupedTieredPackageCompositePriceFilterOperatorTest : TestBase +public class MaxGroupTieredPackageCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Includes)] - [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Excludes)] - public void Validation_Works(GroupedTieredPackageCompositePriceFilterOperator rawValue) + [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Includes)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Excludes)] + public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -50403,7 +64233,7 @@ public void Validation_Works(GroupedTieredPackageCompositePriceFilterOperator ra public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -50411,18 +64241,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Includes)] - [InlineData(GroupedTieredPackageCompositePriceFilterOperator.Excludes)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Includes)] + [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - GroupedTieredPackageCompositePriceFilterOperator rawValue + MaxGroupTieredPackageCompositePriceFilterOperator 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); @@ -50432,23 +64262,23 @@ GroupedTieredPackageCompositePriceFilterOperator 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 GroupedTieredPackageConversionRateConfigTest : TestBase +public class MaxGroupTieredPackageConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() + MaxGroupTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -50459,7 +64289,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() + MaxGroupTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -50479,13 +64309,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() + MaxGroupTieredPackageConversionRateConfig 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 ); @@ -50496,7 +64326,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() + MaxGroupTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -50511,7 +64341,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -50520,28 +64350,28 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedTieredPackageGroupedTieredPackageConfigTest : TestBase +public class MaxGroupTieredPackageMaxGroupTieredPackageConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfig + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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 = + List expectedTiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; Assert.Equal(expectedGroupingKey, model.GroupingKey); @@ -50556,20 +64386,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfig + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -50580,20 +64410,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfig + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -50601,10 +64431,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedGroupingKey = "x"; string expectedPackageSize = "package_size"; - List expectedTiers = + List expectedTiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ]; Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); @@ -50619,51 +64449,70 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfig + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig { GroupingKey = "x", PackageSize = "package_size", Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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 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 GroupedTieredPackageGroupedTieredPackageConfigTierTest : TestBase +public class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier { - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string expectedPerUnit = "per_unit"; string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPerUnit, model.PerUnit); Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier { - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -50674,57 +64523,71 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier { - PerUnit = "per_unit", 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 expectedPerUnit = "per_unit"; string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPerUnit, deserialized.PerUnit); Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier { - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; 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 GroupedTieredPackagePriceTypeTest : TestBase +public class MaxGroupTieredPackagePriceTypeTest : TestBase { [Theory] - [InlineData(GroupedTieredPackagePriceType.UsagePrice)] - [InlineData(GroupedTieredPackagePriceType.FixedPrice)] - [InlineData(GroupedTieredPackagePriceType.CompositePrice)] - public void Validation_Works(GroupedTieredPackagePriceType rawValue) + [InlineData(MaxGroupTieredPackagePriceType.UsagePrice)] + [InlineData(MaxGroupTieredPackagePriceType.FixedPrice)] + [InlineData(MaxGroupTieredPackagePriceType.CompositePrice)] + public void Validation_Works(MaxGroupTieredPackagePriceType 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 ); @@ -50734,17 +64597,17 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(GroupedTieredPackagePriceType.UsagePrice)] - [InlineData(GroupedTieredPackagePriceType.FixedPrice)] - [InlineData(GroupedTieredPackagePriceType.CompositePrice)] - public void SerializationRoundtrip_Works(GroupedTieredPackagePriceType rawValue) + [InlineData(MaxGroupTieredPackagePriceType.UsagePrice)] + [InlineData(MaxGroupTieredPackagePriceType.FixedPrice)] + [InlineData(MaxGroupTieredPackagePriceType.CompositePrice)] + public void SerializationRoundtrip_Works(MaxGroupTieredPackagePriceType 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); @@ -50753,37 +64616,132 @@ public void SerializationRoundtrip_Works(GroupedTieredPackagePriceType 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 MaxGroupTieredPackageTest : TestBase +public class MaxGroupTieredPackageLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MaxGroupTieredPackage + 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] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -50812,6 +64770,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50832,18 +64791,9 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -50877,13 +64827,36 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }, }; string expectedID = "id"; @@ -50893,21 +64866,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - MaxGroupTieredPackageBillingMode.InAdvance; - ApiEnum expectedCadence = - MaxGroupTieredPackageCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + ScalableMatrixWithUnitPricingBillingMode.InAdvance; + ApiEnum expectedCadence = + ScalableMatrixWithUnitPricingCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - MaxGroupTieredPackageConversionRateConfig expectedConversionRateConfig = + ScalableMatrixWithUnitPricingConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -50932,6 +64905,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -50952,22 +64926,13 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - MaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -51000,18 +64965,42 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "max_group_tiered_package" + "scalable_matrix_with_unit_pricing" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - MaxGroupTieredPackagePriceType.UsagePrice; + ApiEnum expectedPriceType = + ScalableMatrixWithUnitPricingPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig 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", + }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -51032,9 +65021,9 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); - Assert.Equal(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); Assert.Equal(expectedMaximum, model.Maximum); Assert.Equal(expectedMaximumAmount, model.MaximumAmount); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); @@ -51051,25 +65040,30 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + model.ScalableMatrixWithUnitPricingConfig + ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51098,6 +65092,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51118,18 +65113,9 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51163,17 +65149,40 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -51184,19 +65193,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51225,6 +65234,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51245,18 +65255,9 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51290,17 +65291,40 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -51313,21 +65337,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - MaxGroupTieredPackageBillingMode.InAdvance; - ApiEnum expectedCadence = - MaxGroupTieredPackageCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + ScalableMatrixWithUnitPricingBillingMode.InAdvance; + ApiEnum expectedCadence = + ScalableMatrixWithUnitPricingCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - MaxGroupTieredPackageConversionRateConfig expectedConversionRateConfig = + ScalableMatrixWithUnitPricingConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -51352,6 +65376,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -51372,22 +65397,13 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day, }; ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - MaxGroupTieredPackageMaxGroupTieredPackageConfig expectedMaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }; Maximum expectedMaximum = new() { AppliesToPriceIds = ["string"], @@ -51420,18 +65436,42 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "max_group_tiered_package" + "scalable_matrix_with_unit_pricing" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - MaxGroupTieredPackagePriceType.UsagePrice; + ApiEnum expectedPriceType = + ScalableMatrixWithUnitPricingPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig 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", + }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -51452,9 +65492,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); - Assert.Equal(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); Assert.Equal(expectedMaximum, deserialized.Maximum); Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); @@ -51471,28 +65511,33 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceType, deserialized.PriceType); Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal( + expectedScalableMatrixWithUnitPricingConfig, + deserialized.ScalableMatrixWithUnitPricingConfig + ); Assert.Equal( expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51521,6 +65566,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51541,18 +65587,9 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51586,13 +65623,36 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }, }; model.Validate(); @@ -51601,19 +65661,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51642,6 +65702,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51662,18 +65723,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51707,30 +65759,49 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51759,6 +65830,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51779,18 +65851,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51824,8 +65887,25 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, }; model.Validate(); @@ -51834,19 +65914,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51875,6 +65955,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51895,18 +65976,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", 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"], @@ -51940,32 +66012,52 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new MaxGroupTieredPackage + var model = new ScalableMatrixWithUnitPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -51994,6 +66086,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52014,18 +66107,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MaxGroupTieredPackageConfig = new() + Maximum = new() + { + AppliesToPriceIds = ["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", - PackageSize = "package_size", - Tiers = + 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() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + 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, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -52059,51 +66271,78 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, + 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", + }, }; - model.Validate(); + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); } } -public class MaxGroupTieredPackageBillingModeTest : TestBase +public class ScalableMatrixWithUnitPricingBillingModeTest : TestBase { [Theory] - [InlineData(MaxGroupTieredPackageBillingMode.InAdvance)] - [InlineData(MaxGroupTieredPackageBillingMode.InArrear)] - public void Validation_Works(MaxGroupTieredPackageBillingMode rawValue) + [InlineData(ScalableMatrixWithUnitPricingBillingMode.InAdvance)] + [InlineData(ScalableMatrixWithUnitPricingBillingMode.InArrear)] + public void Validation_Works(ScalableMatrixWithUnitPricingBillingMode 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(MaxGroupTieredPackageBillingMode.InAdvance)] - [InlineData(MaxGroupTieredPackageBillingMode.InArrear)] - public void SerializationRoundtrip_Works(MaxGroupTieredPackageBillingMode rawValue) + [InlineData(ScalableMatrixWithUnitPricingBillingMode.InAdvance)] + [InlineData(ScalableMatrixWithUnitPricingBillingMode.InArrear)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingBillingMode 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); @@ -52112,62 +66351,60 @@ public void SerializationRoundtrip_Works(MaxGroupTieredPackageBillingMode rawVal [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 MaxGroupTieredPackageCadenceTest : TestBase +public class ScalableMatrixWithUnitPricingCadenceTest : TestBase { [Theory] - [InlineData(MaxGroupTieredPackageCadence.OneTime)] - [InlineData(MaxGroupTieredPackageCadence.Monthly)] - [InlineData(MaxGroupTieredPackageCadence.Quarterly)] - [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] - [InlineData(MaxGroupTieredPackageCadence.Annual)] - [InlineData(MaxGroupTieredPackageCadence.Custom)] - public void Validation_Works(MaxGroupTieredPackageCadence rawValue) + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithUnitPricingCadence 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(MaxGroupTieredPackageCadence.OneTime)] - [InlineData(MaxGroupTieredPackageCadence.Monthly)] - [InlineData(MaxGroupTieredPackageCadence.Quarterly)] - [InlineData(MaxGroupTieredPackageCadence.SemiAnnual)] - [InlineData(MaxGroupTieredPackageCadence.Annual)] - [InlineData(MaxGroupTieredPackageCadence.Custom)] - public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence rawValue) + [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] + [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence 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); @@ -52176,35 +66413,36 @@ public void SerializationRoundtrip_Works(MaxGroupTieredPackageCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class MaxGroupTieredPackageCompositePriceFilterTest : TestBase +public class ScalableMatrixWithUnitPricingCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MaxGroupTieredPackageCompositePriceFilter + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - MaxGroupTieredPackageCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - MaxGroupTieredPackageCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID; + ApiEnum< + string, + ScalableMatrixWithUnitPricingCompositePriceFilterOperator + > expectedOperator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -52219,18 +66457,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new MaxGroupTieredPackageCompositePriceFilter + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -52238,24 +66477,27 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MaxGroupTieredPackageCompositePriceFilter + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedField = - MaxGroupTieredPackageCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - MaxGroupTieredPackageCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID; + ApiEnum< + string, + ScalableMatrixWithUnitPricingCompositePriceFilterOperator + > expectedOperator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -52270,29 +66512,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new MaxGroupTieredPackageCompositePriceFilter + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 MaxGroupTieredPackageCompositePriceFilterFieldTest : TestBase +public class ScalableMatrixWithUnitPricingCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceID)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.ItemID)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceType)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.Currency)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterField rawValue) + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -52300,7 +66557,7 @@ public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterField rawV public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -52308,21 +66565,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceID)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.ItemID)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PriceType)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.Currency)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID)] public void SerializationRoundtrip_Works( - MaxGroupTieredPackageCompositePriceFilterField rawValue + ScalableMatrixWithUnitPricingCompositePriceFilterField 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); @@ -52332,26 +66589,26 @@ MaxGroupTieredPackageCompositePriceFilterField 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 MaxGroupTieredPackageCompositePriceFilterOperatorTest : TestBase +public class ScalableMatrixWithUnitPricingCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Includes)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Excludes)] - public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterOperator rawValue) + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes)] + public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -52359,7 +66616,7 @@ public void Validation_Works(MaxGroupTieredPackageCompositePriceFilterOperator r public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -52367,18 +66624,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Includes)] - [InlineData(MaxGroupTieredPackageCompositePriceFilterOperator.Excludes)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes)] + [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - MaxGroupTieredPackageCompositePriceFilterOperator rawValue + ScalableMatrixWithUnitPricingCompositePriceFilterOperator 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); @@ -52388,144 +66645,483 @@ MaxGroupTieredPackageCompositePriceFilterOperator 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 ScalableMatrixWithUnitPricingConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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() + { + ScalableMatrixWithUnitPricingConversionRateConfig 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 ScalableMatrixWithUnitPricingPriceTypeTest : TestBase +{ + [Theory] + [InlineData(ScalableMatrixWithUnitPricingPriceType.UsagePrice)] + [InlineData(ScalableMatrixWithUnitPricingPriceType.FixedPrice)] + [InlineData(ScalableMatrixWithUnitPricingPriceType.CompositePrice)] + public void Validation_Works(ScalableMatrixWithUnitPricingPriceType rawValue) + { + // force 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(ScalableMatrixWithUnitPricingPriceType.UsagePrice)] + [InlineData(ScalableMatrixWithUnitPricingPriceType.FixedPrice)] + [InlineData(ScalableMatrixWithUnitPricingPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum >(json, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + Assert.Equal(value, deserialized); + } +} + +public class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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", + }; + + 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 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", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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", + }; + + 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 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + 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")); } -} -public class MaxGroupTieredPackageConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - MaxGroupTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - MaxGroupTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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, }; - value.Validate(); + + 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 UnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - MaxGroupTieredPackageConversionRateConfig value = new SharedUnitConversionRateConfig() + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - MaxGroupTieredPackageConversionRateConfig value = new SharedTieredConversionRateConfig() + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + FirstDimension = "first_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(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); } } -public class MaxGroupTieredPackageMaxGroupTieredPackageConfigTest : TestBase +public class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest + : TestBase { [Fact] public void FieldRoundtrip_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" }, - ], - }; + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; - 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" }, - ]; + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; - 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]); - } + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, model.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] public void SerializationRoundtrip_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" }, - ], - }; + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -52536,93 +67132,157 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_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" }, - ], - }; + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + 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" }, - ]; + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedScalingFactor = "scaling_factor"; + string expectedSecondDimensionValue = "second_dimension_value"; - 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]); - } + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] public void Validation_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" }, - ], - }; + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + + SecondDimensionValue = null, + }; 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 MaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest : TestBase +public class ScalableMatrixWithUnitPricingLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + var model = new ScalableMatrixWithUnitPricingLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + var model = new ScalableMatrixWithUnitPricingLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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); } @@ -52630,116 +67290,76 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + var model = new ScalableMatrixWithUnitPricingLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); } [Fact] public void Validation_Works() { - var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + var model = new ScalableMatrixWithUnitPricingLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; model.Validate(); } -} - -public class MaxGroupTieredPackagePriceTypeTest : TestBase -{ - [Theory] - [InlineData(MaxGroupTieredPackagePriceType.UsagePrice)] - [InlineData(MaxGroupTieredPackagePriceType.FixedPrice)] - [InlineData(MaxGroupTieredPackagePriceType.CompositePrice)] - public void Validation_Works(MaxGroupTieredPackagePriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(MaxGroupTieredPackagePriceType.UsagePrice)] - [InlineData(MaxGroupTieredPackagePriceType.FixedPrice)] - [InlineData(MaxGroupTieredPackagePriceType.CompositePrice)] - public void SerializationRoundtrip_Works(MaxGroupTieredPackagePriceType 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 ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; - [Fact] - public 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); + ScalableMatrixWithUnitPricingLicenseType copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class ScalableMatrixWithUnitPricingTest : TestBase +public class ScalableMatrixWithTieredPricingTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -52768,6 +67388,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52788,6 +67409,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -52823,9 +67445,9 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -52837,8 +67459,11 @@ public void FieldRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = new() @@ -52846,6 +67471,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -52855,21 +67486,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - ScalableMatrixWithUnitPricingBillingMode.InAdvance; - ApiEnum expectedCadence = - ScalableMatrixWithUnitPricingCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + ScalableMatrixWithTieredPricingBillingMode.InAdvance; + ApiEnum expectedCadence = + ScalableMatrixWithTieredPricingCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - ScalableMatrixWithUnitPricingConversionRateConfig expectedConversionRateConfig = + ScalableMatrixWithTieredPricingConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -52894,6 +67525,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -52914,6 +67546,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -52952,14 +67585,14 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "scalable_matrix_with_unit_pricing" + "scalable_matrix_with_tiered_pricing" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - ScalableMatrixWithUnitPricingPriceType.UsagePrice; + ApiEnum expectedPriceType = + ScalableMatrixWithTieredPricingPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", @@ -52972,8 +67605,11 @@ public void FieldRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() @@ -52981,6 +67617,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); @@ -53001,6 +67643,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -53020,28 +67663,29 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal( - expectedScalableMatrixWithUnitPricingConfig, - model.ScalableMatrixWithUnitPricingConfig + expectedScalableMatrixWithTieredPricingConfig, + model.ScalableMatrixWithTieredPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53070,6 +67714,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53090,6 +67735,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53125,9 +67771,9 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53139,8 +67785,11 @@ public void SerializationRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = new() @@ -53148,10 +67797,16 @@ 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); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -53162,19 +67817,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53203,6 +67858,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53223,6 +67879,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53258,9 +67915,9 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53272,8 +67929,11 @@ public void FieldRoundtripThroughSerialization_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = new() @@ -53281,10 +67941,16 @@ 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); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -53297,21 +67963,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - ScalableMatrixWithUnitPricingBillingMode.InAdvance; - ApiEnum expectedCadence = - ScalableMatrixWithUnitPricingCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + ScalableMatrixWithTieredPricingBillingMode.InAdvance; + ApiEnum expectedCadence = + ScalableMatrixWithTieredPricingCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - ScalableMatrixWithUnitPricingConversionRateConfig expectedConversionRateConfig = + ScalableMatrixWithTieredPricingConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -53336,6 +68002,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -53356,6 +68023,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -53394,14 +68062,14 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "scalable_matrix_with_unit_pricing" + "scalable_matrix_with_tiered_pricing" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - ScalableMatrixWithUnitPricingPriceType.UsagePrice; + ApiEnum expectedPriceType = + ScalableMatrixWithTieredPricingPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig expectedScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig expectedScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", @@ -53414,8 +68082,11 @@ public void FieldRoundtripThroughSerialization_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() @@ -53423,6 +68094,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); @@ -53443,6 +68120,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -53462,31 +68140,32 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedPriceType, deserialized.PriceType); Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); Assert.Equal( - expectedScalableMatrixWithUnitPricingConfig, - deserialized.ScalableMatrixWithUnitPricingConfig + expectedScalableMatrixWithTieredPricingConfig, + deserialized.ScalableMatrixWithTieredPricingConfig ); Assert.Equal( expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53515,6 +68194,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53535,6 +68215,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53570,9 +68251,9 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53584,8 +68265,11 @@ public void Validation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = new() @@ -53593,6 +68277,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -53601,19 +68291,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53642,6 +68332,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53662,6 +68353,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53697,9 +68389,9 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53711,32 +68403,164 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + 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, + InvoiceGroupingKey = "invoice_grouping_key", + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53765,6 +68589,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53785,6 +68610,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53820,9 +68646,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53834,31 +68660,40 @@ public void OptionalNullablePropertiesUnsetValidation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, + + 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 ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -53887,6 +68722,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53907,6 +68743,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -53942,9 +68779,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -53956,34 +68793,37 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, 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 ScalableMatrixWithUnitPricing + var model = new ScalableMatrixWithTieredPricing { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -54012,6 +68852,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54032,6 +68873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -54067,9 +68909,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54081,27 +68923,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }, - - DimensionalPriceConfiguration = null, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; - model.Validate(); + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); } } -public class ScalableMatrixWithUnitPricingBillingModeTest : TestBase +public class ScalableMatrixWithTieredPricingBillingModeTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithUnitPricingBillingMode.InAdvance)] - [InlineData(ScalableMatrixWithUnitPricingBillingMode.InArrear)] - public void Validation_Works(ScalableMatrixWithUnitPricingBillingMode rawValue) + [InlineData(ScalableMatrixWithTieredPricingBillingMode.InAdvance)] + [InlineData(ScalableMatrixWithTieredPricingBillingMode.InArrear)] + public void Validation_Works(ScalableMatrixWithTieredPricingBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -54109,7 +68965,7 @@ public void Validation_Works(ScalableMatrixWithUnitPricingBillingMode rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -54117,16 +68973,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithUnitPricingBillingMode.InAdvance)] - [InlineData(ScalableMatrixWithUnitPricingBillingMode.InArrear)] - public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingBillingMode rawValue) + [InlineData(ScalableMatrixWithTieredPricingBillingMode.InAdvance)] + [InlineData(ScalableMatrixWithTieredPricingBillingMode.InArrear)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingBillingMode 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); @@ -54136,30 +68992,30 @@ public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingBillingMod 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 ScalableMatrixWithUnitPricingCadenceTest : TestBase +public class ScalableMatrixWithTieredPricingCadenceTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] - [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] - public void Validation_Works(ScalableMatrixWithUnitPricingCadence rawValue) + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void Validation_Works(ScalableMatrixWithTieredPricingCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -54167,7 +69023,7 @@ public void Validation_Works(ScalableMatrixWithUnitPricingCadence rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -54175,20 +69031,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithUnitPricingCadence.OneTime)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Monthly)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Quarterly)] - [InlineData(ScalableMatrixWithUnitPricingCadence.SemiAnnual)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Annual)] - [InlineData(ScalableMatrixWithUnitPricingCadence.Custom)] - public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence rawValue) + [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] + [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] + [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence 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); @@ -54198,35 +69054,35 @@ public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingCadence ra 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 ScalableMatrixWithUnitPricingCompositePriceFilterTest : TestBase +public class ScalableMatrixWithTieredPricingCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID; + ApiEnum expectedField = + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID; ApiEnum< string, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator - > expectedOperator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes; + ScalableMatrixWithTieredPricingCompositePriceFilterOperator + > expectedOperator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -54241,16 +69097,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -54261,27 +69117,27 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID; + ApiEnum expectedField = + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID; ApiEnum< string, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator - > expectedOperator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes; + ScalableMatrixWithTieredPricingCompositePriceFilterOperator + > expectedOperator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -54296,29 +69152,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 ScalableMatrixWithUnitPricingCompositePriceFilterFieldTest : TestBase +public class ScalableMatrixWithTieredPricingCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterField rawValue) + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(ScalableMatrixWithTieredPricingCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -54326,7 +69197,7 @@ public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterFi public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -54334,21 +69205,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID)] public void SerializationRoundtrip_Works( - ScalableMatrixWithUnitPricingCompositePriceFilterField rawValue + ScalableMatrixWithTieredPricingCompositePriceFilterField 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); @@ -54358,26 +69229,29 @@ ScalableMatrixWithUnitPricingCompositePriceFilterField 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 ScalableMatrixWithUnitPricingCompositePriceFilterOperatorTest : TestBase +public class ScalableMatrixWithTieredPricingCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes)] - public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterOperator rawValue) + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes)] + public void Validation_Works( + ScalableMatrixWithTieredPricingCompositePriceFilterOperator rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = + rawValue; value.Validate(); } @@ -54385,7 +69259,7 @@ public void Validation_Works(ScalableMatrixWithUnitPricingCompositePriceFilterOp public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -54393,18 +69267,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes)] - [InlineData(ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes)] + [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - ScalableMatrixWithUnitPricingCompositePriceFilterOperator rawValue + ScalableMatrixWithTieredPricingCompositePriceFilterOperator 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); @@ -54414,23 +69289,23 @@ ScalableMatrixWithUnitPricingCompositePriceFilterOperator 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 ScalableMatrixWithUnitPricingConversionRateConfigTest : TestBase +public class ScalableMatrixWithTieredPricingConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ScalableMatrixWithUnitPricingConversionRateConfig value = + ScalableMatrixWithTieredPricingConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -54442,7 +69317,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ScalableMatrixWithUnitPricingConversionRateConfig value = + ScalableMatrixWithTieredPricingConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -54463,7 +69338,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ScalableMatrixWithUnitPricingConversionRateConfig value = + ScalableMatrixWithTieredPricingConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -54471,7 +69346,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -54482,7 +69357,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ScalableMatrixWithUnitPricingConversionRateConfig value = + ScalableMatrixWithTieredPricingConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -54499,7 +69374,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -54508,16 +69383,16 @@ public void TieredSerializationRoundtripWorks() } } -public class ScalableMatrixWithUnitPricingPriceTypeTest : TestBase +public class ScalableMatrixWithTieredPricingPriceTypeTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithUnitPricingPriceType.UsagePrice)] - [InlineData(ScalableMatrixWithUnitPricingPriceType.FixedPrice)] - [InlineData(ScalableMatrixWithUnitPricingPriceType.CompositePrice)] - public void Validation_Works(ScalableMatrixWithUnitPricingPriceType rawValue) + [InlineData(ScalableMatrixWithTieredPricingPriceType.UsagePrice)] + [InlineData(ScalableMatrixWithTieredPricingPriceType.FixedPrice)] + [InlineData(ScalableMatrixWithTieredPricingPriceType.CompositePrice)] + public void Validation_Works(ScalableMatrixWithTieredPricingPriceType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -54525,7 +69400,7 @@ public void Validation_Works(ScalableMatrixWithUnitPricingPriceType rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -54533,17 +69408,17 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithUnitPricingPriceType.UsagePrice)] - [InlineData(ScalableMatrixWithUnitPricingPriceType.FixedPrice)] - [InlineData(ScalableMatrixWithUnitPricingPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingPriceType rawValue) + [InlineData(ScalableMatrixWithTieredPricingPriceType.UsagePrice)] + [InlineData(ScalableMatrixWithTieredPricingPriceType.FixedPrice)] + [InlineData(ScalableMatrixWithTieredPricingPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingPriceType 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); @@ -54553,23 +69428,23 @@ public void SerializationRoundtrip_Works(ScalableMatrixWithUnitPricingPriceType 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigTest : TestBase +public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54581,13 +69456,16 @@ public void FieldRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + 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 = + List expectedMatrixScalingFactors = [ new() { @@ -54596,8 +69474,11 @@ public void FieldRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ]; - string expectedUnitPrice = "unit_price"; - bool expectedProrate = true; + 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); @@ -54606,15 +69487,18 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } - Assert.Equal(expectedUnitPrice, model.UnitPrice); - Assert.Equal(expectedProrate, model.Prorate); + 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54626,14 +69510,17 @@ public void SerializationRoundtrip_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -54644,7 +69531,7 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54656,21 +69543,24 @@ public void FieldRoundtripThroughSerialization_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); string expectedFirstDimension = "first_dimension"; - List expectedMatrixScalingFactors = + List expectedMatrixScalingFactors = [ new() { @@ -54679,8 +69569,11 @@ public void FieldRoundtripThroughSerialization_Works() SecondDimensionValue = "second_dimension_value", }, ]; - string expectedUnitPrice = "unit_price"; - bool expectedProrate = true; + 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); @@ -54689,15 +69582,18 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } - Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); - Assert.Equal(expectedProrate, deserialized.Prorate); + 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54709,8 +69605,11 @@ public void Validation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", - Prorate = true, + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], SecondDimension = "second_dimension", }; @@ -54720,7 +69619,7 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54732,11 +69631,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }; - Assert.Null(model.Prorate); - Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); Assert.False(model.RawData.ContainsKey("second_dimension")); } @@ -54744,7 +69645,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54756,7 +69657,11 @@ public void OptionalNullablePropertiesUnsetValidation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }; model.Validate(); @@ -54765,7 +69670,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54777,14 +69682,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], - Prorate = null, SecondDimension = null, }; - Assert.Null(model.Prorate); - Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); Assert.True(model.RawData.ContainsKey("second_dimension")); } @@ -54792,7 +69698,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig { FirstDimension = "first_dimension", MatrixScalingFactors = @@ -54804,24 +69710,55 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() SecondDimensionValue = "second_dimension_value", }, ], - UnitPrice = "unit_price", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], - Prorate = null, SecondDimension = null, }; 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 ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest +public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54841,7 +69778,7 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54850,7 +69787,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -54862,7 +69799,7 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54871,7 +69808,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -54890,7 +69827,7 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54904,7 +69841,7 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54918,7 +69855,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54931,7 +69868,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54947,7 +69884,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor { FirstDimensionValue = "first_dimension_value", ScalingFactor = "scaling_factor", @@ -54957,26 +69894,228 @@ 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 ScalableMatrixWithTieredPricingTest : TestBase +public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + 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 ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -55005,6 +70144,20 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55025,6 +70178,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -55060,32 +70214,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.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", + }, }; string expectedID = "id"; @@ -55095,21 +70236,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - ScalableMatrixWithTieredPricingBillingMode.InAdvance; - ApiEnum expectedCadence = - ScalableMatrixWithTieredPricingCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + CumulativeGroupedBulkBillingMode.InAdvance; + ApiEnum expectedCadence = + CumulativeGroupedBulkCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - ScalableMatrixWithTieredPricingConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedBulkConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -55134,6 +70275,20 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }; + CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55154,6 +70309,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -55192,38 +70348,24 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "scalable_matrix_with_tiered_pricing" + "cumulative_grouped_bulk" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - ScalableMatrixWithTieredPricingPriceType.UsagePrice; + ApiEnum expectedPriceType = + CumulativeGroupedBulkPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig 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", - }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -55240,10 +70382,12 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCreditAllocation, model.CreditAllocation); + Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); Assert.Equal(expectedCurrency, model.Currency); Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -55262,29 +70406,26 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal( - expectedScalableMatrixWithTieredPricingConfig, - model.ScalableMatrixWithTieredPricingConfig - ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -55313,6 +70454,20 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55333,6 +70488,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -55368,36 +70524,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -55408,19 +70551,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -55449,6 +70592,20 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55469,6 +70626,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -55504,36 +70662,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -55546,21 +70691,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - ScalableMatrixWithTieredPricingBillingMode.InAdvance; - ApiEnum expectedCadence = - ScalableMatrixWithTieredPricingCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + CumulativeGroupedBulkBillingMode.InAdvance; + ApiEnum expectedCadence = + CumulativeGroupedBulkCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - ScalableMatrixWithTieredPricingConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedBulkConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -55585,6 +70730,20 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }; + CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55605,6 +70764,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -55643,38 +70803,24 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "scalable_matrix_with_tiered_pricing" + "cumulative_grouped_bulk" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - ScalableMatrixWithTieredPricingPriceType.UsagePrice; + ApiEnum expectedPriceType = + CumulativeGroupedBulkPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig 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", - }; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -55691,10 +70837,12 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCreditAllocation, deserialized.CreditAllocation); + Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); Assert.Equal(expectedCurrency, deserialized.Currency); Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -55713,32 +70861,29 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceType, deserialized.PriceType); Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal( - expectedScalableMatrixWithTieredPricingConfig, - deserialized.ScalableMatrixWithTieredPricingConfig - ); Assert.Equal( expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -55767,6 +70912,20 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55787,6 +70946,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -55822,32 +70982,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.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", + }, }; model.Validate(); @@ -55856,19 +71003,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -55897,6 +71044,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55917,6 +71078,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -55952,49 +71114,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -56023,6 +71168,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56043,6 +71202,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -56078,48 +71238,156 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithTieredPricingConfig = new() + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CumulativeGroupedBulk + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + 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() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], }, ], - Tiers = + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], - SecondDimension = "second_dimension", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = 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 ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -56148,6 +71416,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56168,6 +71450,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -56203,51 +71486,32 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.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 = 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 ScalableMatrixWithTieredPricing + var model = new CumulativeGroupedBulk { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -56276,6 +71540,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56296,6 +71574,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -56331,69 +71610,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithTieredPricingConfig = new() + DimensionalPriceConfiguration = 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", + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - - DimensionalPriceConfiguration = null, }; - model.Validate(); + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); } } -public class ScalableMatrixWithTieredPricingBillingModeTest : TestBase +public class CumulativeGroupedBulkBillingModeTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithTieredPricingBillingMode.InAdvance)] - [InlineData(ScalableMatrixWithTieredPricingBillingMode.InArrear)] - public void Validation_Works(ScalableMatrixWithTieredPricingBillingMode rawValue) + [InlineData(CumulativeGroupedBulkBillingMode.InAdvance)] + [InlineData(CumulativeGroupedBulkBillingMode.InArrear)] + public void Validation_Works(CumulativeGroupedBulkBillingMode 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ScalableMatrixWithTieredPricingBillingMode.InAdvance)] - [InlineData(ScalableMatrixWithTieredPricingBillingMode.InArrear)] - public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingBillingMode rawValue) + [InlineData(CumulativeGroupedBulkBillingMode.InAdvance)] + [InlineData(CumulativeGroupedBulkBillingMode.InArrear)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkBillingMode 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); @@ -56402,60 +71674,62 @@ public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingBillingM [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 ScalableMatrixWithTieredPricingCadenceTest : TestBase +public class CumulativeGroupedBulkCadenceTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] - [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] - public void Validation_Works(ScalableMatrixWithTieredPricingCadence rawValue) + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void Validation_Works(CumulativeGroupedBulkCadence 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ScalableMatrixWithTieredPricingCadence.OneTime)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Monthly)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Quarterly)] - [InlineData(ScalableMatrixWithTieredPricingCadence.SemiAnnual)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Annual)] - [InlineData(ScalableMatrixWithTieredPricingCadence.Custom)] - public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence rawValue) + [InlineData(CumulativeGroupedBulkCadence.OneTime)] + [InlineData(CumulativeGroupedBulkCadence.Monthly)] + [InlineData(CumulativeGroupedBulkCadence.Quarterly)] + [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] + [InlineData(CumulativeGroupedBulkCadence.Annual)] + [InlineData(CumulativeGroupedBulkCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence 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); @@ -56464,36 +71738,35 @@ public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingCadence [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 ScalableMatrixWithTieredPricingCompositePriceFilterTest : TestBase +public class CumulativeGroupedBulkCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + var model = new CumulativeGroupedBulkCompositePriceFilter { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID; - ApiEnum< - string, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator - > expectedOperator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedBulkCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedBulkCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -56508,19 +71781,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + var model = new CumulativeGroupedBulkCompositePriceFilter { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -56528,27 +71800,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + var model = new CumulativeGroupedBulkCompositePriceFilter { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedField = - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID; - ApiEnum< - string, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator - > expectedOperator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedBulkCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedBulkCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -56563,29 +71832,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + var model = new CumulativeGroupedBulkCompositePriceFilter { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 ScalableMatrixWithTieredPricingCompositePriceFilterFieldTest : TestBase +public class CumulativeGroupedBulkCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(ScalableMatrixWithTieredPricingCompositePriceFilterField rawValue) + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -56593,7 +71877,7 @@ public void Validation_Works(ScalableMatrixWithTieredPricingCompositePriceFilter public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -56601,21 +71885,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID)] public void SerializationRoundtrip_Works( - ScalableMatrixWithTieredPricingCompositePriceFilterField rawValue + CumulativeGroupedBulkCompositePriceFilterField 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); @@ -56625,29 +71909,26 @@ ScalableMatrixWithTieredPricingCompositePriceFilterField 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 ScalableMatrixWithTieredPricingCompositePriceFilterOperatorTest : TestBase +public class CumulativeGroupedBulkCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes)] - public void Validation_Works( - ScalableMatrixWithTieredPricingCompositePriceFilterOperator rawValue - ) + [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Excludes)] + public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -56655,7 +71936,7 @@ ScalableMatrixWithTieredPricingCompositePriceFilterOperator rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -56663,19 +71944,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes)] - [InlineData(ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - ScalableMatrixWithTieredPricingCompositePriceFilterOperator rawValue + CumulativeGroupedBulkCompositePriceFilterOperator 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); @@ -56685,67 +71965,63 @@ ScalableMatrixWithTieredPricingCompositePriceFilterOperator 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 ScalableMatrixWithTieredPricingConversionRateConfigTest : TestBase +public class CumulativeGroupedBulkConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ScalableMatrixWithTieredPricingConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + CumulativeGroupedBulkConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - ScalableMatrixWithTieredPricingConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + CumulativeGroupedBulkConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - ScalableMatrixWithTieredPricingConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + CumulativeGroupedBulkConversionRateConfig 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); } @@ -56753,170 +72029,88 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ScalableMatrixWithTieredPricingConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + CumulativeGroupedBulkConversionRateConfig 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 ScalableMatrixWithTieredPricingPriceTypeTest : TestBase -{ - [Theory] - [InlineData(ScalableMatrixWithTieredPricingPriceType.UsagePrice)] - [InlineData(ScalableMatrixWithTieredPricingPriceType.FixedPrice)] - [InlineData(ScalableMatrixWithTieredPricingPriceType.CompositePrice)] - public void Validation_Works(ScalableMatrixWithTieredPricingPriceType rawValue) - { - // force 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(ScalableMatrixWithTieredPricingPriceType.UsagePrice)] - [InlineData(ScalableMatrixWithTieredPricingPriceType.FixedPrice)] - [InlineData(ScalableMatrixWithTieredPricingPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(ScalableMatrixWithTieredPricingPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = 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 deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTest : TestBase +public class CumulativeGroupedBulkCumulativeGroupedBulkConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig { - FirstDimension = "first_dimension", - MatrixScalingFactors = + DimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], - SecondDimension = "second_dimension", + Group = "group", }; - string expectedFirstDimension = "first_dimension"; - List expectedMatrixScalingFactors = + List expectedDimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ]; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - string expectedSecondDimension = "second_dimension"; + string expectedGroup = "group"; - 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(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) { - Assert.Equal(expectedTiers[i], model.Tiers[i]); + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); } - Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.Equal(expectedGroup, model.Group); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig { - FirstDimension = "first_dimension", - MatrixScalingFactors = + DimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + Group = "group", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -56927,235 +72121,124 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig { - FirstDimension = "first_dimension", - MatrixScalingFactors = + DimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + Group = "group", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedFirstDimension = "first_dimension"; - List expectedMatrixScalingFactors = + List expectedDimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ]; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - string expectedSecondDimension = "second_dimension"; + string expectedGroup = "group"; - 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(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); } - Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.Equal(expectedGroup, deserialized.Group); } [Fact] public void Validation_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", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_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" }, - ], - }; - - Assert.Null(model.SecondDimension); - Assert.False(model.RawData.ContainsKey("second_dimension")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig { - FirstDimension = "first_dimension", - MatrixScalingFactors = + DimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + Group = "group", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void CopyConstructor_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig { - FirstDimension = "first_dimension", - MatrixScalingFactors = + DimensionValues = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - - SecondDimension = null, + Group = "group", }; - Assert.Null(model.SecondDimension); - Assert.True(model.RawData.ContainsKey("second_dimension")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_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" }, - ], + CumulativeGroupedBulkCumulativeGroupedBulkConfig copied = new(model); - SecondDimension = null, - }; - - model.Validate(); + Assert.Equal(model, copied); } } -public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest - : TestBase +public class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }; + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - string expectedFirstDimensionValue = "first_dimension_value"; - string expectedScalingFactor = "scaling_factor"; - string expectedSecondDimensionValue = "second_dimension_value"; + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); - Assert.Equal(expectedScalingFactor, model.ScalingFactor); - Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }; + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + 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 ); @@ -57166,137 +72249,153 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }; + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + 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 expectedFirstDimensionValue = "first_dimension_value"; - string expectedScalingFactor = "scaling_factor"; - string expectedSecondDimensionValue = "second_dimension_value"; + string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); - Assert.Equal(expectedScalingFactor, deserialized.ScalingFactor); - Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }; + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - }; + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Null(model.SecondDimensionValue); - Assert.False(model.RawData.ContainsKey("second_dimension_value")); + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CumulativeGroupedBulkPriceTypeTest : TestBase +{ + [Theory] + [InlineData(CumulativeGroupedBulkPriceType.UsagePrice)] + [InlineData(CumulativeGroupedBulkPriceType.FixedPrice)] + [InlineData(CumulativeGroupedBulkPriceType.CompositePrice)] + public void Validation_Works(CumulativeGroupedBulkPriceType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void InvalidEnumValidationThrows_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + [Theory] + [InlineData(CumulativeGroupedBulkPriceType.UsagePrice)] + [InlineData(CumulativeGroupedBulkPriceType.FixedPrice)] + [InlineData(CumulativeGroupedBulkPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(CumulativeGroupedBulkPriceType rawValue) { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - SecondDimensionValue = null, - }; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Null(model.SecondDimensionValue); - Assert.True(model.RawData.ContainsKey("second_dimension_value")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = - new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - - SecondDimensionValue = null, - }; + 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 ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest : TestBase +public class CumulativeGroupedBulkLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + var model = new CumulativeGroupedBulkLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + var model = new CumulativeGroupedBulkLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; 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); } @@ -57304,58 +72403,76 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + var model = new CumulativeGroupedBulkLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); } [Fact] public void Validation_Works() { - var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + var model = new CumulativeGroupedBulkLicenseType { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + 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 CumulativeGroupedBulkTest : TestBase +public class CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -57384,19 +72501,14 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57417,6 +72529,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -57452,13 +72565,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + 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", + }, }; string expectedID = "id"; @@ -57468,21 +72587,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - CumulativeGroupedBulkBillingMode.InAdvance; - ApiEnum expectedCadence = - CumulativeGroupedBulkCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + CumulativeGroupedAllocationBillingMode.InAdvance; + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - CumulativeGroupedBulkConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -57507,19 +72626,14 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; - CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -57540,6 +72654,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -57578,18 +72693,24 @@ public void FieldRoundtrip_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_bulk" + "cumulative_grouped_allocation" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - CumulativeGroupedBulkPriceType.UsagePrice; + ApiEnum expectedPriceType = + CumulativeGroupedAllocationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -57606,11 +72727,15 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCreditAllocation, model.CreditAllocation); - Assert.Equal(expectedCumulativeGroupedBulkConfig, model.CumulativeGroupedBulkConfig); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedCurrency, model.Currency); Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -57630,24 +72755,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -57676,19 +72802,14 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57709,6 +72830,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -57744,17 +72866,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + 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", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -57765,19 +72893,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -57806,19 +72934,14 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -57839,6 +72962,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -57874,17 +72998,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + 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", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -57897,21 +73027,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - CumulativeGroupedBulkBillingMode.InAdvance; - ApiEnum expectedCadence = - CumulativeGroupedBulkCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + CumulativeGroupedAllocationBillingMode.InAdvance; + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - CumulativeGroupedBulkConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -57936,19 +73066,14 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; - CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -57969,6 +73094,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -58007,18 +73133,24 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMinimumAmount = "minimum_amount"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_bulk" + "cumulative_grouped_allocation" ); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - CumulativeGroupedBulkPriceType.UsagePrice; + ApiEnum expectedPriceType = + CumulativeGroupedAllocationPriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { 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); @@ -58035,11 +73167,15 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCreditAllocation, deserialized.CreditAllocation); - Assert.Equal(expectedCumulativeGroupedBulkConfig, deserialized.CumulativeGroupedBulkConfig); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedCurrency, deserialized.Currency); Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -58049,37 +73185,164 @@ public void FieldRoundtripThroughSerialization_Works() { 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(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 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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", + }, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -58108,19 +73371,14 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58141,6 +73399,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -58176,34 +73435,32 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.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 CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -58232,19 +73489,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58265,6 +73517,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -58300,30 +73553,29 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, 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 CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -58352,19 +73604,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58385,6 +73632,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -58420,29 +73668,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.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 CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -58471,19 +73725,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58504,6 +73753,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -58539,32 +73789,32 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, 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 CumulativeGroupedBulk + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -58593,19 +73843,14 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedBulkConfig = new() + CumulativeGroupedAllocationConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, Currency = "currency", Discount = new PercentageDiscount() @@ -58626,6 +73871,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -58661,51 +73907,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.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(); + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class CumulativeGroupedBulkBillingModeTest : TestBase +public class CumulativeGroupedAllocationBillingModeTest : TestBase { [Theory] - [InlineData(CumulativeGroupedBulkBillingMode.InAdvance)] - [InlineData(CumulativeGroupedBulkBillingMode.InArrear)] - public void Validation_Works(CumulativeGroupedBulkBillingMode rawValue) + [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] + [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] + public void Validation_Works(CumulativeGroupedAllocationBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(CumulativeGroupedBulkBillingMode.InAdvance)] - [InlineData(CumulativeGroupedBulkBillingMode.InArrear)] - public void SerializationRoundtrip_Works(CumulativeGroupedBulkBillingMode rawValue) + [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] + [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -58714,39 +73970,38 @@ public void SerializationRoundtrip_Works(CumulativeGroupedBulkBillingMode rawVal [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 CumulativeGroupedBulkCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(CumulativeGroupedBulkCadence.OneTime)] - [InlineData(CumulativeGroupedBulkCadence.Monthly)] - [InlineData(CumulativeGroupedBulkCadence.Quarterly)] - [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] - [InlineData(CumulativeGroupedBulkCadence.Annual)] - [InlineData(CumulativeGroupedBulkCadence.Custom)] - public void Validation_Works(CumulativeGroupedBulkCadence rawValue) + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -58756,20 +74011,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedBulkCadence.OneTime)] - [InlineData(CumulativeGroupedBulkCadence.Monthly)] - [InlineData(CumulativeGroupedBulkCadence.Quarterly)] - [InlineData(CumulativeGroupedBulkCadence.SemiAnnual)] - [InlineData(CumulativeGroupedBulkCadence.Annual)] - [InlineData(CumulativeGroupedBulkCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence rawValue) + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -58778,35 +74033,35 @@ public void SerializationRoundtrip_Works(CumulativeGroupedBulkCadence 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 CumulativeGroupedBulkCompositePriceFilterTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedBulkCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - CumulativeGroupedBulkCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedBulkCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -58821,18 +74076,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedBulkCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -58840,24 +74096,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedBulkCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedField = - CumulativeGroupedBulkCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedBulkCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -58872,29 +74129,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedBulkCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; 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 CumulativeGroupedBulkCompositePriceFilterFieldTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterField rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -58902,7 +74174,7 @@ public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterField rawV public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -58910,21 +74182,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] public void SerializationRoundtrip_Works( - CumulativeGroupedBulkCompositePriceFilterField rawValue + CumulativeGroupedAllocationCompositePriceFilterField rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -58934,26 +74206,26 @@ CumulativeGroupedBulkCompositePriceFilterField 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 CumulativeGroupedBulkCompositePriceFilterOperatorTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Excludes)] - public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterOperator rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -58961,7 +74233,7 @@ public void Validation_Works(CumulativeGroupedBulkCompositePriceFilterOperator r public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -58969,282 +74241,159 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedBulkCompositePriceFilterOperator.Excludes)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - CumulativeGroupedBulkCompositePriceFilterOperator rawValue + CumulativeGroupedAllocationCompositePriceFilterOperator rawValue ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedBulkConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - CumulativeGroupedBulkConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - CumulativeGroupedBulkConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - CumulativeGroupedBulkConversionRateConfig 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() - { - CumulativeGroupedBulkConversionRateConfig 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 - ); + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedBulkCumulativeGroupedBulkConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] - public void FieldRoundtrip_Works() + public void UnitValidationWorks() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig + CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + value.Validate(); + } - List expectedDimensionValues = - [ - new() + [Fact] + public void TieredValidationWorks() + { + CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() { - 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); + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void UnitSerializationRoundtripWorks() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig + CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - 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 TieredSerializationRoundtripWorks() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + 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 CumulativeGroupedBulkCumulativeGroupedBulkConfig - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }; - model.Validate(); + Assert.Equal(value, deserialized); } } -public class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - 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); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + var model = new CumulativeGroupedAllocationConfig { + 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( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -59252,81 +74401,99 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + var model = new CumulativeGroupedAllocationConfig { + 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( - 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 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); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + var model = new CumulativeGroupedAllocationConfig { + 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 CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedBulkPriceTypeTest : TestBase +public class CumulativeGroupedAllocationPriceTypeTest : TestBase { [Theory] - [InlineData(CumulativeGroupedBulkPriceType.UsagePrice)] - [InlineData(CumulativeGroupedBulkPriceType.FixedPrice)] - [InlineData(CumulativeGroupedBulkPriceType.CompositePrice)] - public void Validation_Works(CumulativeGroupedBulkPriceType rawValue) + [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] + [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] + [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] + public void Validation_Works(CumulativeGroupedAllocationPriceType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(CumulativeGroupedBulkPriceType.UsagePrice)] - [InlineData(CumulativeGroupedBulkPriceType.FixedPrice)] - [InlineData(CumulativeGroupedBulkPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(CumulativeGroupedBulkPriceType rawValue) + [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] + [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] + [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationPriceType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -59335,37 +74502,131 @@ public void SerializationRoundtrip_Works(CumulativeGroupedBulkPriceType rawValue [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationTest : TestBase +public class CumulativeGroupedAllocationLicenseTypeTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + 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 DailyCreditAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -59394,15 +74655,17 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -59421,6 +74684,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -59456,13 +74720,19 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.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"; @@ -59472,21 +74742,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - CumulativeGroupedAllocationBillingMode.InAdvance; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + DailyCreditAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -59511,15 +74781,17 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + string expectedCurrency = "currency"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -59538,6 +74810,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -59575,19 +74848,23 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - CumulativeGroupedAllocationPriceType.UsagePrice; + ApiEnum expectedPriceType = + DailyCreditAllowancePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + DailyCreditAllowanceLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -59604,14 +74881,12 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCreditAllocation, model.CreditAllocation); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -59631,24 +74906,25 @@ 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] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -59677,15 +74953,17 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -59704,6 +74982,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -59739,17 +75018,23 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -59760,19 +75045,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -59801,15 +75086,17 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -59828,6 +75115,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -59863,17 +75151,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -59886,21 +75180,21 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - CumulativeGroupedAllocationBillingMode.InAdvance; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + DailyCreditAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -59925,15 +75219,17 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + string expectedCurrency = "currency"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -59952,6 +75248,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -59989,19 +75286,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = - CumulativeGroupedAllocationPriceType.UsagePrice; + ApiEnum expectedPriceType = + DailyCreditAllowancePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + DailyCreditAllowanceLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -60018,14 +75319,12 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); Assert.Equal(expectedCreditAllocation, deserialized.CreditAllocation); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -60048,24 +75347,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60094,15 +75394,17 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -60121,6 +75423,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -60156,13 +75459,19 @@ public void Validation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -60171,19 +75480,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60212,15 +75521,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -60239,6 +75550,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -60274,30 +75586,32 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.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 CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60326,15 +75640,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -60353,6 +75669,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -60388,7 +75705,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -60398,19 +75715,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60439,15 +75756,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -60466,6 +75785,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -60501,32 +75821,35 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.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 CumulativeGroupedAllocation + var model = new DailyCreditAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60555,15 +75878,17 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, - CumulativeGroupedAllocationConfig = new() + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", Discount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -60582,6 +75907,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -60617,50 +75943,181 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, + PriceType = DailyCreditAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowance + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.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", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 = DailyCreditAllowancePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationBillingModeTest : TestBase +public class DailyCreditAllowanceBillingModeTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] - [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] - public void Validation_Works(CumulativeGroupedAllocationBillingMode rawValue) + [InlineData(DailyCreditAllowanceBillingMode.InAdvance)] + [InlineData(DailyCreditAllowanceBillingMode.InArrear)] + public void Validation_Works(DailyCreditAllowanceBillingMode 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] - [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationBillingMode rawValue) + [InlineData(DailyCreditAllowanceBillingMode.InAdvance)] + [InlineData(DailyCreditAllowanceBillingMode.InArrear)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceBillingMode 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); @@ -60669,38 +76126,39 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationBillingMode [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 CumulativeGroupedAllocationCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(DailyCreditAllowanceCadence 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 ); @@ -60710,21 +76168,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCadence 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); } @@ -60732,35 +76191,36 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationCompositePriceFilterTest : TestBase +public class DailyCreditAllowanceCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationCompositePriceFilter + var model = new DailyCreditAllowanceCompositePriceFilter { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - CumulativeGroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + DailyCreditAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + DailyCreditAllowanceCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -60775,19 +76235,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationCompositePriceFilter + var model = new DailyCreditAllowanceCompositePriceFilter { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -60795,25 +76254,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationCompositePriceFilter + var model = new DailyCreditAllowanceCompositePriceFilter { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedField = - CumulativeGroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedField = + DailyCreditAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + DailyCreditAllowanceCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -60828,29 +76286,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationCompositePriceFilter + var model = new DailyCreditAllowanceCompositePriceFilter { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceCompositePriceFilter + { + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + DailyCreditAllowanceCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase +public class DailyCreditAllowanceCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterField rawValue) + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PriceID)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.ItemID)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PriceType)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.Currency)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(DailyCreditAllowanceCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -60858,7 +76331,7 @@ public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterFiel public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -60866,21 +76339,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works( - CumulativeGroupedAllocationCompositePriceFilterField rawValue - ) + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PriceID)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.ItemID)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PriceType)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.Currency)] + [InlineData(DailyCreditAllowanceCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCompositePriceFilterField 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); @@ -60890,26 +76361,26 @@ CumulativeGroupedAllocationCompositePriceFilterField 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 CumulativeGroupedAllocationCompositePriceFilterOperatorTest : TestBase +public class DailyCreditAllowanceCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterOperator rawValue) + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Includes)] + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Excludes)] + public void Validation_Works(DailyCreditAllowanceCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -60917,7 +76388,7 @@ public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterOper public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -60925,18 +76396,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Includes)] + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Excludes)] public void SerializationRoundtrip_Works( - CumulativeGroupedAllocationCompositePriceFilterOperator rawValue + DailyCreditAllowanceCompositePriceFilterOperator 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); @@ -60946,23 +76417,23 @@ CumulativeGroupedAllocationCompositePriceFilterOperator 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() + DailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -60973,38 +76444,36 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + DailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() + DailyCreditAllowanceConversionRateConfig 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); } @@ -61012,69 +76481,198 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + DailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -61085,83 +76683,94 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationPriceTypeTest : TestBase +public class DailyCreditAllowancePriceTypeTest : TestBase { [Theory] - [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] - [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] - [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] - public void Validation_Works(CumulativeGroupedAllocationPriceType rawValue) + [InlineData(DailyCreditAllowancePriceType.UsagePrice)] + [InlineData(DailyCreditAllowancePriceType.FixedPrice)] + [InlineData(DailyCreditAllowancePriceType.CompositePrice)] + public void Validation_Works(DailyCreditAllowancePriceType 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] - [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] - [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationPriceType rawValue) + [InlineData(DailyCreditAllowancePriceType.UsagePrice)] + [InlineData(DailyCreditAllowancePriceType.FixedPrice)] + [InlineData(DailyCreditAllowancePriceType.CompositePrice)] + public void SerializationRoundtrip_Works(DailyCreditAllowancePriceType 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); @@ -61170,36 +76779,132 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationPriceType ra [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 PriceMinimumTest : TestBase +public class DailyCreditAllowanceLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceLicenseType + { + 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 DailyCreditAllowanceLicenseType + { + 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 DailyCreditAllowanceLicenseType + { + 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 DailyCreditAllowanceLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + DailyCreditAllowanceLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -61228,6 +76933,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -61248,6 +76954,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -61266,6 +76973,15 @@ public void FieldRoundtrip_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -61281,16 +76997,21 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.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 +77021,20 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MeteredAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = MeteredAllowanceCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -61338,6 +77059,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -61358,6 +77080,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -61380,6 +77103,15 @@ public void FieldRoundtrip_Works() }; string expectedMaximumAmount = "maximum_amount"; Dictionary expectedMetadata = new() { { "foo", "string" } }; + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; Minimum expectedMinimum = new() { AppliesToPriceIds = ["string"], @@ -61395,21 +77127,23 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + MeteredAllowancePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MeteredAllowanceLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -61430,6 +77164,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -61441,33 +77176,168 @@ public void FieldRoundtrip_Works() Assert.Equal(value, model.Metadata[item.Key]); } + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.Equal(expectedMinimum, model.Minimum); Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimum + var model = new MeteredAllowance + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.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, + InvoiceGroupingKey = "invoice_grouping_key", + 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" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + 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 = MeteredAllowancePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + 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 MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -61496,6 +77366,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -61516,6 +77387,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -61534,6 +77406,15 @@ public void SerializationRoundtrip_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -61549,138 +77430,25 @@ public void SerializationRoundtrip_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.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() + LicenseType = new() { - 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -61693,20 +77461,20 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MeteredAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = MeteredAllowanceCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -61731,6 +77499,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -61751,6 +77520,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -61773,6 +77543,15 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedMaximumAmount = "maximum_amount"; Dictionary expectedMetadata = new() { { "foo", "string" } }; + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; Minimum expectedMinimum = new() { AppliesToPriceIds = ["string"], @@ -61788,21 +77567,23 @@ public void FieldRoundtripThroughSerialization_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.UsagePrice; + ApiEnum expectedPriceType = + MeteredAllowancePriceType.UsagePrice; string expectedReplacesPriceID = "replaces_price_id"; DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MeteredAllowanceLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -61823,6 +77604,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -61834,9 +77616,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(value, deserialized.Metadata[item.Key]); } + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); 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); @@ -61846,24 +77628,25 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] public void Validation_Works() { - var model = new PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -61892,6 +77675,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -61912,6 +77696,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -61930,6 +77715,15 @@ public void Validation_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -61945,16 +77739,21 @@ public void Validation_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -61963,19 +77762,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62004,6 +77803,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62024,6 +77824,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -62042,6 +77843,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -62057,33 +77867,34 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.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 PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62112,6 +77923,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62132,6 +77944,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -62150,6 +77963,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -62165,10 +77987,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -62178,19 +77999,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62219,6 +78040,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62239,6 +78061,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -62257,6 +78080,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -62272,35 +78104,37 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.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 PriceMinimum + var model = new MeteredAllowance { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62329,6 +78163,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62349,6 +78184,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -62367,6 +78203,15 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, MaximumAmount = "maximum_amount", Metadata = new Dictionary() { { "foo", "string" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Minimum = new() { AppliesToPriceIds = ["string"], @@ -62382,35 +78227,165 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MeteredAllowancePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowance + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MeteredAllowanceBillingMode.InAdvance, + Cadence = MeteredAllowanceCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.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, + InvoiceGroupingKey = "invoice_grouping_key", + 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" } }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + 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 = MeteredAllowancePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceMinimumBillingModeTest : TestBase +public class MeteredAllowanceBillingModeTest : TestBase { [Theory] - [InlineData(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void Validation_Works(PriceMinimumBillingMode rawValue) + [InlineData(MeteredAllowanceBillingMode.InAdvance)] + [InlineData(MeteredAllowanceBillingMode.InArrear)] + public void Validation_Works(MeteredAllowanceBillingMode 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 ); @@ -62420,15 +78395,15 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void SerializationRoundtrip_Works(PriceMinimumBillingMode rawValue) + [InlineData(MeteredAllowanceBillingMode.InAdvance)] + [InlineData(MeteredAllowanceBillingMode.InArrear)] + public void SerializationRoundtrip_Works(MeteredAllowanceBillingMode 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 ); @@ -62439,12 +78414,12 @@ public void SerializationRoundtrip_Works(PriceMinimumBillingMode 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 ); @@ -62453,26 +78428,26 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceMinimumCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : TestBase { [Theory] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.Custom)] - public void Validation_Works(PriceMinimumCadence rawValue) + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void Validation_Works(MeteredAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -62482,19 +78457,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(MeteredAllowanceCadence 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 ); @@ -62505,12 +78480,12 @@ public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -62519,22 +78494,22 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceMinimumCompositePriceFilterTest : TestBase +public class MeteredAllowanceCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new MeteredAllowanceCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MeteredAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MeteredAllowanceCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -62549,15 +78524,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new MeteredAllowanceCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -62568,24 +78543,24 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new MeteredAllowanceCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + MeteredAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + MeteredAllowanceCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -62600,29 +78575,44 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new MeteredAllowanceCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceCompositePriceFilter + { + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MeteredAllowanceCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceMinimumCompositePriceFilterFieldTest : TestBase +public class MeteredAllowanceCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(PriceMinimumCompositePriceFilterField rawValue) + [InlineData(MeteredAllowanceCompositePriceFilterField.PriceID)] + [InlineData(MeteredAllowanceCompositePriceFilterField.ItemID)] + [InlineData(MeteredAllowanceCompositePriceFilterField.PriceType)] + [InlineData(MeteredAllowanceCompositePriceFilterField.Currency)] + [InlineData(MeteredAllowanceCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(MeteredAllowanceCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -62630,7 +78620,7 @@ public void Validation_Works(PriceMinimumCompositePriceFilterField rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -62638,19 +78628,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterField rawValue) + [InlineData(MeteredAllowanceCompositePriceFilterField.PriceID)] + [InlineData(MeteredAllowanceCompositePriceFilterField.ItemID)] + [InlineData(MeteredAllowanceCompositePriceFilterField.PriceType)] + [InlineData(MeteredAllowanceCompositePriceFilterField.Currency)] + [InlineData(MeteredAllowanceCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works(MeteredAllowanceCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -62660,26 +78650,26 @@ public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterField r public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumCompositePriceFilterOperatorTest : TestBase +public class MeteredAllowanceCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void Validation_Works(PriceMinimumCompositePriceFilterOperator rawValue) + [InlineData(MeteredAllowanceCompositePriceFilterOperator.Includes)] + [InlineData(MeteredAllowanceCompositePriceFilterOperator.Excludes)] + public void Validation_Works(MeteredAllowanceCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -62687,7 +78677,7 @@ public void Validation_Works(PriceMinimumCompositePriceFilterOperator rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -62695,16 +78685,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterOperator rawValue) + [InlineData(MeteredAllowanceCompositePriceFilterOperator.Includes)] + [InlineData(MeteredAllowanceCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works(MeteredAllowanceCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -62714,23 +78704,23 @@ public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterOperato public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -62741,7 +78731,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -62761,13 +78751,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig 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 ); @@ -62778,7 +78768,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -62793,7 +78783,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -62802,27 +78792,51 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumConfigTest : TestBase +public class MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -62833,26 +78847,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; model.Validate(); } @@ -62860,16 +78898,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -62877,50 +78929,78 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceMinimumPriceTypeTest : TestBase +public class MeteredAllowancePriceTypeTest : TestBase { [Theory] - [InlineData(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void Validation_Works(PriceMinimumPriceType rawValue) + [InlineData(MeteredAllowancePriceType.UsagePrice)] + [InlineData(MeteredAllowancePriceType.FixedPrice)] + [InlineData(MeteredAllowancePriceType.CompositePrice)] + public void Validation_Works(MeteredAllowancePriceType 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 ); @@ -62930,16 +79010,16 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(PriceMinimumPriceType rawValue) + [InlineData(MeteredAllowancePriceType.UsagePrice)] + [InlineData(MeteredAllowancePriceType.FixedPrice)] + [InlineData(MeteredAllowancePriceType.CompositePrice)] + public void SerializationRoundtrip_Works(MeteredAllowancePriceType 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 ); @@ -62950,12 +79030,12 @@ public void SerializationRoundtrip_Works(PriceMinimumPriceType 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 ); @@ -62964,6 +79044,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MeteredAllowanceLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MeteredAllowanceLicenseType + { + 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 MeteredAllowanceLicenseType + { + 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 MeteredAllowanceLicenseType + { + 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 MeteredAllowanceLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MeteredAllowanceLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MinimumCompositeTest : TestBase { [Fact] @@ -63010,6 +79185,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63030,6 +79206,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -63073,6 +79250,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -63120,6 +79303,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -63140,6 +79324,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -63193,6 +79378,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MinimumCompositeLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -63213,6 +79404,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -63233,6 +79425,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] @@ -63279,6 +79472,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63299,6 +79493,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -63342,6 +79537,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); @@ -63397,6 +79598,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63417,6 +79619,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -63460,6 +79663,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 +79723,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -63534,6 +79744,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -63587,6 +79798,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); @@ -63607,6 +79824,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -63630,6 +79848,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -63676,6 +79895,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63696,6 +79916,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -63739,6 +79960,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 +80015,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63808,6 +80036,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -63850,6 +80079,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 +80127,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63916,6 +80148,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -64003,6 +80236,122 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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() @@ -64023,6 +80372,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -64063,14 +80413,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 +80463,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64133,6 +80484,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -64171,11 +80523,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 +80756,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 +81080,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 +81156,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 +81297,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64830,6 +81318,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -64873,6 +81362,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 +81414,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -64939,6 +81435,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -64987,6 +81484,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); @@ -65007,6 +81510,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedDiscount, model.Discount); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -65027,6 +81531,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 +81578,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65093,6 +81599,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65136,6 +81643,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 +81701,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65208,6 +81722,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65251,6 +81766,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 +81825,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -65324,6 +81846,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -65372,6 +81895,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); @@ -65392,6 +81921,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedDiscount, deserialized.Discount); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -65415,6 +81945,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -65461,6 +81992,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65481,6 +82013,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65524,6 +82057,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 +82112,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65593,6 +82133,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65635,6 +82176,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 +82224,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65701,6 +82245,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65788,6 +82333,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65808,6 +82354,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65848,10 +82395,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 +82448,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65918,6 +82469,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -65958,10 +82510,133 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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 +82853,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 +83113,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 +83185,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 +83326,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66557,6 +83353,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -66599,6 +83396,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 +83449,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -66672,6 +83476,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -66719,6 +83524,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); @@ -66740,6 +83551,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -66759,6 +83571,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 +83618,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66831,6 +83645,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -66873,6 +83688,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 +83749,309 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; + 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(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + 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() @@ -66954,6 +84078,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -66996,180 +84121,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 +84176,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67238,6 +84203,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -67275,18 +84241,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 +84293,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67355,6 +84320,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -67394,12 +84360,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 +84407,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67468,6 +84434,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -67505,13 +84472,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 +84527,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67580,6 +84554,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -67619,14 +84594,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 +84644,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67695,6 +84671,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -67732,11 +84709,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 +84942,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 +85278,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 +85354,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..e62a2080f 100644 --- a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs @@ -22,9 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/prices/external_price_id/external_price_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/prices/external_price_id/external_price_id"), + 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..28b52dfe1 100644 --- a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs @@ -59,9 +59,25 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/prices/external_price_id/external_price_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/prices/external_price_id/external_price_id"), + 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..05c0a4a2c 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,13 +139,65 @@ public void Url_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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,75 @@ public void NewFloatingMatrixWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Body value = new MatrixWithThresholdDiscounts() + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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(); @@ -889,6 +1025,7 @@ public void NewFloatingTieredWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -932,6 +1069,7 @@ public void NewFloatingUnitWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -980,6 +1118,7 @@ public void NewFloatingGroupedAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1028,6 +1167,7 @@ public void NewFloatingBulkWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1077,6 +1217,7 @@ public void NewFloatingGroupedWithProratedMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1135,6 +1276,7 @@ public void NewFloatingGroupedWithMeteredMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1183,6 +1325,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1239,6 +1382,7 @@ public void NewFloatingMatrixWithDisplayNamePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1291,6 +1435,7 @@ public void NewFloatingGroupedTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1344,6 +1489,7 @@ public void NewFloatingMaxGroupTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1373,6 +1519,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -1403,6 +1550,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1465,6 +1613,7 @@ public void NewFloatingScalableMatrixWithTieredPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1521,6 +1670,7 @@ public void NewFloatingCumulativeGroupedBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1569,20 +1719,79 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + Body value = new DailyCreditAllowance() + { + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "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(); } [Fact] - public void MinimumValidationWorks() + public void MeteredAllowanceValidationWorks() { - Body value = new Minimum() + Body value = new MeteredAllowance() { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -1611,6 +1820,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1654,6 +1864,7 @@ public void NewFloatingMinimumCompositePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1696,6 +1907,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1743,6 +1955,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1786,6 +1999,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 +2058,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 +2105,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 +2159,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 +2206,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 +2258,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 +2313,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 +2368,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 +2434,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 +2489,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 +2555,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 +2608,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 +2655,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 +2708,78 @@ 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); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + Body value = new MatrixWithThresholdDiscounts() + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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); @@ -2530,6 +2828,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 +2875,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 +2927,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 +2979,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 +3032,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 +3094,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 +3146,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 +3206,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 +3262,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 +3319,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 +3352,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceSerializationRoundtripW }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3074,6 +3383,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 +3449,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 +3509,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,6 +3561,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3258,14 +3571,21 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - Body value = new Minimum() + Body value = new DailyCreditAllowance() { - Cadence = MinimumCadence.Annual, + Cadence = DailyCreditAllowanceCadence.Annual, Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3294,6 +3614,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3303,15 +3624,22 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - Body value = new Models::NewFloatingMinimumCompositePrice() + Body value = new MeteredAllowance() { - Cadence = Models::NewFloatingMinimumCompositePriceCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewFloatingMinimumCompositePriceModelType.MinimumComposite, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3340,6 +3668,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); @@ -3349,15 +3678,16 @@ public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() { - Body value = new Percent() + Body value = new Models::NewFloatingMinimumCompositePrice() { - Cadence = PercentCadence.Annual, + Cadence = Models::NewFloatingMinimumCompositePriceCadence.Annual, Currency = "currency", ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewFloatingMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3385,6 +3715,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); @@ -3394,20 +3725,15 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Body value = new EventOutput() + Body value = new Percent() { - Cadence = EventOutputCadence.Annual, + Cadence = PercentCadence.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() @@ -3435,6 +3761,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); @@ -3442,17 +3769,68 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class BulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void EventOutputSerializationRoundtripWorks() { - var model = new BulkWithFilters + Body value = new EventOutput() { - BulkWithFiltersConfig = new() - { + 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" } }, + }; + 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 = [ @@ -3491,6 +3869,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3536,6 +3915,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 +3934,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +3990,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3666,6 +4048,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3718,6 +4101,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 +4123,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +4179,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3840,6 +4226,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +4284,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -3919,6 +4308,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +4343,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 +4515,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 +4583,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 +4687,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 @@ -4358,23 +4842,42 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class MatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4403,22 +4906,42 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; string expectedCurrency = "currency"; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -4429,7 +4952,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -4449,15 +4972,16 @@ 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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig ); - Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -4470,6 +4994,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -4483,18 +5008,37 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4523,11 +5067,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 ); @@ -4538,18 +5083,37 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MatrixWithThresholdDiscounts { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + Cadence = MatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4578,29 +5142,49 @@ 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 = - GroupedWithMinMaxThresholdsCadence.Annual; + ApiEnum expectedCadence = + MatrixWithThresholdDiscountsCadence.Annual; string expectedCurrency = "currency"; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + string expectedItemID = "item_id"; + MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -4611,7 +5195,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -4631,12 +5215,1674 @@ 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( - expectedGroupedWithMinMaxThresholdsConfig, + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscounts + { + Cadence = MatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force 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(MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(MatrixWithThresholdDiscountsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class MatrixWithThresholdDiscountsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + MatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdDiscountGroupTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + ThresholdDiscountGroup copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + MatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "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, + 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" } }, + }; + + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + 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( + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = 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, + 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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + GroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + 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( + expectedGroupedWithMinMaxThresholdsConfig, deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); @@ -4655,6 +6901,831 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + 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 +{ + [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 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 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", + }, + 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" } }, + }; + + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedCurrency = "currency"; + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedCurrency, model.Currency); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = 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", + }, + 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" } }, + }; + + 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 expectedCurrency = "currency"; + 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; + CumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedCurrency, deserialized.Currency); + 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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -4668,17 +7739,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -4708,6 +7779,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4717,17 +7789,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -4752,6 +7824,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -4759,17 +7833,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -4780,17 +7854,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -4804,6 +7878,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4827,6 +7902,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -4834,17 +7911,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new CumulativeGroupedAllocation { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -4858,33 +7935,86 @@ 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 GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : 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(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; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -4894,20 +8024,20 @@ 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(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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -4916,56 +8046,56 @@ 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 + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class GroupedWithMinMaxThresholdsConfigTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -4976,53 +8106,69 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5034,7 +8180,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5055,7 +8201,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5063,7 +8209,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5074,7 +8220,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5091,7 +8237,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5100,22 +8246,23 @@ public void TieredSerializationRoundtripWorks() } } -public class CumulativeGroupedAllocationTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5145,23 +8292,23 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5171,7 +8318,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5191,14 +8338,12 @@ 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( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5212,6 +8357,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5225,17 +8371,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5265,11 +8412,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 ); @@ -5280,17 +8428,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5320,30 +8469,30 @@ 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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5353,7 +8502,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5373,14 +8522,12 @@ 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( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); + + Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -5397,6 +8544,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5410,17 +8558,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5450,6 +8599,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5459,17 +8609,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -5494,6 +8645,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5501,17 +8654,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -5522,17 +8676,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -5546,6 +8701,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5569,6 +8725,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5576,17 +8734,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new DailyCreditAllowance { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -5600,33 +8759,87 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowance + { + Cadence = DailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : 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(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(DailyCreditAllowanceCadence 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 ); @@ -5636,21 +8849,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) + [InlineData(DailyCreditAllowanceCadence.Annual)] + [InlineData(DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(DailyCreditAllowanceCadence.Monthly)] + [InlineData(DailyCreditAllowanceCadence.Quarterly)] + [InlineData(DailyCreditAllowanceCadence.OneTime)] + [InlineData(DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(DailyCreditAllowanceCadence 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); } @@ -5658,56 +8872,188 @@ public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawV [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5718,53 +9064,63 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5776,7 +9132,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5797,18 +9153,17 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new 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); } @@ -5816,7 +9171,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5832,27 +9187,34 @@ 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 MinimumTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5881,18 +9243,23 @@ 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 = MeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5902,7 +9269,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5922,12 +9289,13 @@ 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -5940,6 +9308,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,12 +9322,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5987,11 +9364,15 @@ 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,12 +9380,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6033,25 +9422,30 @@ 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 = MeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6061,7 +9455,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6081,12 +9475,13 @@ 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -6102,6 +9497,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,12 +9511,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6149,6 +9553,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6158,12 +9563,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -6187,6 +9600,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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,12 +9609,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -6209,12 +9632,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -6227,6 +9658,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6250,6 +9682,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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,12 +9691,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new MeteredAllowance { - Cadence = MinimumCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -6275,33 +9717,88 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowance + { + Cadence = MeteredAllowanceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void Validation_Works(MeteredAllowanceCadence 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 +9808,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(MeteredAllowanceCadence.Annual)] + [InlineData(MeteredAllowanceCadence.SemiAnnual)] + [InlineData(MeteredAllowanceCadence.Monthly)] + [InlineData(MeteredAllowanceCadence.Quarterly)] + [InlineData(MeteredAllowanceCadence.OneTime)] + [InlineData(MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(MeteredAllowanceCadence 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 +9831,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 +9845,51 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6379,26 +9900,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; model.Validate(); } @@ -6406,16 +9951,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -6423,39 +9982,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new MeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -6466,7 +10053,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -6486,13 +10073,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + MeteredAllowanceConversionRateConfig 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 +10090,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -6518,7 +10105,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6566,6 +10153,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6603,6 +10191,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); @@ -6621,6 +10210,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6668,6 +10258,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6714,6 +10305,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6758,6 +10350,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); @@ -6779,6 +10372,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6826,6 +10420,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6864,6 +10459,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6904,6 +10501,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6927,6 +10525,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6952,11 +10552,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 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 PercentCadenceTest : TestBase @@ -7075,6 +10722,16 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PercentConfig { Percent = 0 }; + + PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentConversionRateConfigTest : TestBase @@ -7198,6 +10855,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7240,6 +10898,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); @@ -7258,6 +10917,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7310,6 +10970,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7364,6 +11025,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7413,6 +11075,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 +11097,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11150,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7529,6 +11194,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +11246,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7602,6 +11270,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +11302,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 +11555,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..66c728609 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", @@ -307,7 +327,76 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices/evaluate"), url); + Assert.True(TestBase.UrisEqual(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); } } @@ -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,75 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Price value = new PriceMatrixWithThresholdDiscounts() + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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(); @@ -1665,6 +1972,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1708,6 +2016,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1756,6 +2065,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1804,6 +2114,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1853,6 +2164,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1911,6 +2223,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1959,6 +2272,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2015,6 +2329,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2067,6 +2382,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2120,6 +2436,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2149,6 +2466,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2179,6 +2497,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2560,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2617,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2345,20 +2666,28 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - Price value = new PriceMinimum() + Price value = new PriceDailyCreditAllowance() { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceDailyCreditAllowanceCadence.Annual, Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2387,21 +2716,29 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingMinimumCompositeValidationWorks() + public void MeteredAllowanceValidationWorks() { - Price value = new Models::NewFloatingMinimumCompositePrice() + Price value = new PriceMeteredAllowance() { - Cadence = Models::NewFloatingMinimumCompositePriceCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewFloatingMinimumCompositePriceModelType.MinimumComposite, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2430,21 +2767,23 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void PercentValidationWorks() + public void NewFloatingMinimumCompositeValidationWorks() { - Price value = new PricePercent() + Price value = new Models::NewFloatingMinimumCompositePrice() { - Cadence = PricePercentCadence.Annual, + Cadence = Models::NewFloatingMinimumCompositePriceCadence.Annual, Currency = "currency", ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewFloatingMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2472,26 +2811,22 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void EventOutputValidationWorks() + public void PercentValidationWorks() { - Price value = new PriceEventOutput() + Price value = new PricePercent() { - Cadence = PriceEventOutputCadence.Annual, + Cadence = PricePercentCadence.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() @@ -2519,22 +2854,71 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingUnitSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - Price value = new Models::NewFloatingUnitPrice() + Price value = new PriceEventOutput() { - Cadence = Models::NewFloatingUnitPriceCadence.Annual, + Cadence = PriceEventOutputCadence.Annual, Currency = "currency", - ItemID = "item_id", - ModelType = Models::NewFloatingUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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" } }, + }; + value.Validate(); + } + + [Fact] + public void NewFloatingUnitSerializationRoundtripWorks() + { + Price value = 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() @@ -2562,6 +2946,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 +3005,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 +3052,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 +3106,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 +3153,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 +3205,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 +3260,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 +3315,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 +3381,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 +3436,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 +3502,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 +3555,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 +3602,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 +3655,78 @@ 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); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + Price value = new PriceMatrixWithThresholdDiscounts() + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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); @@ -3306,6 +3775,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 +3822,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 +3874,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 +3926,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 +3979,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 +4041,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 +4093,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 +4153,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 +4209,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 +4266,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 +4299,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3850,6 +4330,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 +4396,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 +4456,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,6 +4508,60 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DailyCreditAllowanceSerializationRoundtripWorks() + { + Price value = new PriceDailyCreditAllowance() + { + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "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); @@ -4034,14 +4571,22 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - Price value = new PriceMinimum() + Price value = new PriceMeteredAllowance() { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4070,6 +4615,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4116,6 +4662,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 +4708,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 +4759,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 +4816,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4313,6 +4863,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 +4882,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +4938,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4443,6 +4996,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4496,6 +5050,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 +5072,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +5128,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4618,6 +5175,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +5233,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4697,6 +5257,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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,11 +5292,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 PriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = PriceBulkWithFiltersCadence.Annual, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -4853,6 +5470,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 +5562,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 +5700,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 @@ -5200,20 +5863,2327 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceGroupedWithMinMaxThresholdsTest : TestBase +public class PriceMatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceMatrixWithThresholdDiscounts { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + ApiEnum expectedCadence = + PriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceMatrixWithThresholdDiscountsConversionRateConfig 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, + }; + 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + PriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceMatrixWithThresholdDiscountsConversionRateConfig 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, + }; + 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( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceMatrixWithThresholdDiscounts + { + Cadence = PriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + PriceMatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceMatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(PriceMatrixWithThresholdDiscountsCadence rawValue) + { + // force 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(PriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(PriceMatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works(PriceMatrixWithThresholdDiscountsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceMatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceMatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceMatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceMatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + PriceMatrixWithThresholdDiscountsConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "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, + 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" } }, + }; + + ApiEnum expectedCadence = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + 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( + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = 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, + 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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + PriceGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + 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( + 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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + 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", @@ -5245,23 +8215,330 @@ public void FieldRoundtrip_Works() 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 +{ + [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", + }, + 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" } }, }; - ApiEnum expectedCadence = - PriceGroupedWithMinMaxThresholdsCadence.Annual; - string expectedCurrency = "currency"; - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCurrency = "currency"; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -5272,7 +8549,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5292,14 +8569,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); + Assert.Equal(expectedCurrency, model.Currency); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5313,6 +8591,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5326,17 +8605,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5366,11 +8645,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 ); @@ -5381,17 +8661,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5421,30 +8701,31 @@ 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 = - PriceGroupedWithMinMaxThresholdsCadence.Annual; - string expectedCurrency = "currency"; - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + ApiEnum expectedCadence = + PriceCumulativeGroupedAllocationCadence.Annual; + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCurrency = "currency"; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -5455,7 +8736,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5475,14 +8756,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); + Assert.Equal(expectedCurrency, deserialized.Currency); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -5499,6 +8781,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5512,17 +8795,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5552,6 +8835,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5561,17 +8845,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -5596,6 +8880,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5603,17 +8889,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -5624,17 +8910,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -5648,6 +8934,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5671,6 +8958,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5678,17 +8967,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceGroupedWithMinMaxThresholds + var model = new PriceCumulativeGroupedAllocation { - Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -5702,26 +8991,79 @@ 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 PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class PriceCumulativeGroupedAllocationCadenceTest : 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) + [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; + ApiEnum value = rawValue; value.Validate(); } @@ -5729,7 +9071,7 @@ public void Validation_Works(PriceGroupedWithMinMaxThresholdsCadence rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -5737,20 +9079,20 @@ public void InvalidEnumValidationThrows_Works() } [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) + [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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -5760,55 +9102,55 @@ public void SerializationRoundtrip_Works(PriceGroupedWithMinMaxThresholdsCadence 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 PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase +public class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5819,54 +9161,70 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 PriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5878,7 +9236,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5899,7 +9257,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5907,7 +9265,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5918,7 +9276,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5935,7 +9293,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5944,22 +9302,23 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceCumulativeGroupedAllocationTest : TestBase +public class PriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5989,24 +9348,24 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = - PriceCumulativeGroupedAllocationCadence.Annual; - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + PriceDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + PriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6016,7 +9375,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6036,14 +9395,12 @@ 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( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -6057,6 +9414,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6070,17 +9428,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6110,11 +9469,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 ); @@ -6125,17 +9485,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6165,31 +9526,31 @@ 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 = - PriceCumulativeGroupedAllocationCadence.Annual; - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + PriceDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + PriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6199,7 +9560,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6219,14 +9580,12 @@ 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( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -6243,6 +9602,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6256,17 +9616,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6296,6 +9657,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6305,17 +9667,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -6340,6 +9703,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6347,17 +9712,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -6368,17 +9734,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -6392,6 +9759,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6415,6 +9783,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6422,17 +9792,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceCumulativeGroupedAllocation + var model = new PriceDailyCreditAllowance { - Cadence = PriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -6446,55 +9817,110 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceDailyCreditAllowance + { + Cadence = PriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceDailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceCumulativeGroupedAllocationCadenceTest : TestBase +public class PriceDailyCreditAllowanceCadenceTest : 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) + [InlineData(PriceDailyCreditAllowanceCadence.Annual)] + [InlineData(PriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(PriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(PriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(PriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(PriceDailyCreditAllowanceCadence.Custom)] + public void Validation_Works(PriceDailyCreditAllowanceCadence 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< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + 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) + [InlineData(PriceDailyCreditAllowanceCadence.Annual)] + [InlineData(PriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(PriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(PriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(PriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(PriceDailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(PriceDailyCreditAllowanceCadence 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); @@ -6503,56 +9929,190 @@ public void SerializationRoundtrip_Works(PriceCumulativeGroupedAllocationCadence [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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 PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase +public class PriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + PriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6563,54 +10123,64 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class PriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceCumulativeGroupedAllocationConversionRateConfig value = + PriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6622,7 +10192,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceCumulativeGroupedAllocationConversionRateConfig value = + PriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6643,7 +10213,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceCumulativeGroupedAllocationConversionRateConfig value = + PriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6651,7 +10221,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6662,7 +10232,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceCumulativeGroupedAllocationConversionRateConfig value = + PriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6679,7 +10249,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6688,17 +10258,25 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceMinimumTest : TestBase +public class PriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6727,18 +10305,24 @@ 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 = + PriceMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() + PriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6748,7 +10332,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6768,12 +10352,13 @@ 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -6786,6 +10371,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,12 +10385,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6833,11 +10427,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,12 +10443,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6882,25 +10485,31 @@ 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 = + PriceMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() + PriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6910,7 +10519,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6930,12 +10539,13 @@ 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -6951,6 +10561,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,12 +10575,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6998,6 +10617,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7007,12 +10627,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -7036,6 +10664,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7043,12 +10673,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -7058,12 +10696,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -7076,6 +10722,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7099,6 +10746,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7106,12 +10755,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceMinimum + var model = new PriceMeteredAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -7124,33 +10781,88 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; - model.Validate(); + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceMeteredAllowance + { + Cadence = PriceMeteredAllowanceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + 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" } }, + }; + + PriceMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); } } -public class PriceMinimumCadenceTest : TestBase +public class PriceMeteredAllowanceCadenceTest : 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) + [InlineData(PriceMeteredAllowanceCadence.Annual)] + [InlineData(PriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(PriceMeteredAllowanceCadence.Monthly)] + [InlineData(PriceMeteredAllowanceCadence.Quarterly)] + [InlineData(PriceMeteredAllowanceCadence.OneTime)] + [InlineData(PriceMeteredAllowanceCadence.Custom)] + public void Validation_Works(PriceMeteredAllowanceCadence 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 ); @@ -7160,22 +10872,21 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(PriceMeteredAllowanceCadence.Annual)] + [InlineData(PriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(PriceMeteredAllowanceCadence.Monthly)] + [InlineData(PriceMeteredAllowanceCadence.Quarterly)] + [InlineData(PriceMeteredAllowanceCadence.OneTime)] + [InlineData(PriceMeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(PriceMeteredAllowanceCadence 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); } @@ -7183,49 +10894,64 @@ public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumMinimumConfigTest : TestBase +public class PriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7236,33 +10962,49 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -7271,16 +11013,30 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new PriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new PriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new PriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -7288,76 +11044,107 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new PriceMinimumMinimumConfig + var model = new PriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + PriceMeteredAllowanceMeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceMinimumConversionRateConfigTest : TestBase +public class PriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PriceMeteredAllowanceConversionRateConfig 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, - }, - ] - ), - }; + PriceMeteredAllowanceConversionRateConfig 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"), - }; + PriceMeteredAllowanceConversionRateConfig 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 ); @@ -7368,22 +11155,23 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PriceMeteredAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = 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 ); @@ -7431,6 +11219,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7468,6 +11257,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); @@ -7486,6 +11276,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7533,6 +11324,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7582,6 +11374,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7626,6 +11419,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); @@ -7647,6 +11441,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7694,6 +11489,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7732,6 +11528,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +11570,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7795,6 +11594,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +11621,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 +11791,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 +11924,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8108,6 +11967,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 +11986,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12039,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8232,6 +12094,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8281,6 +12144,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 +12166,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12219,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8397,6 +12263,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +12315,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8470,6 +12339,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +12371,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 +12624,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..2e3c181ff 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] @@ -136,6 +171,31 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id/evaluate"), url); + Assert.True( + TestBase.UrisEqual(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..6f95fe729 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", @@ -373,7 +393,95 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices/evaluate_preview_events"), url); + Assert.True( + TestBase.UrisEqual( + 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); } } @@ -571,6 +679,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 +711,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 +750,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -629,6 +762,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 +802,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 +815,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 +835,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 +874,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -747,6 +898,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 +937,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -801,6 +957,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 +997,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 +1010,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 +1035,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 +1074,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -911,6 +1090,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 +1129,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -962,6 +1146,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 +1185,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1012,6 +1201,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 +1240,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1066,6 +1260,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 +1299,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1124,6 +1323,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 +1351,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -1158,6 +1360,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 +1377,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 +1484,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1276,6 +1540,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1319,6 +1584,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1371,6 +1637,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1414,6 +1681,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1462,6 +1730,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1514,6 +1783,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1566,6 +1836,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1629,6 +1900,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1681,6 +1953,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1744,6 +2017,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1793,6 +2067,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1837,6 +2112,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1890,25 +2166,51 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingTieredWithProrationValidationWorks() + public void MatrixWithThresholdDiscountsValidationWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new NewFloatingTieredWithProrationPrice() + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts() { - Cadence = NewFloatingTieredWithProrationPriceCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", ItemID = "item_id", - ModelType = NewFloatingTieredWithProrationPriceModelType.TieredWithProration, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1936,23 +2238,26 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingUnitWithProrationValidationWorks() + public void NewFloatingTieredWithProrationValidationWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new NewFloatingUnitWithProrationPrice() + new NewFloatingTieredWithProrationPrice() { - Cadence = NewFloatingUnitWithProrationPriceCadence.Annual, + Cadence = NewFloatingTieredWithProrationPriceCadence.Annual, Currency = "currency", ItemID = "item_id", - ModelType = NewFloatingUnitWithProrationPriceModelType.UnitWithProration, + ModelType = NewFloatingTieredWithProrationPriceModelType.TieredWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1980,28 +2285,24 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingGroupedAllocationValidationWorks() + public void NewFloatingUnitWithProrationValidationWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new NewFloatingGroupedAllocationPrice() + new NewFloatingUnitWithProrationPrice() { - Cadence = NewFloatingGroupedAllocationPriceCadence.Annual, + Cadence = NewFloatingUnitWithProrationPriceCadence.Annual, Currency = "currency", - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, ItemID = "item_id", - ModelType = NewFloatingGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = NewFloatingUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2029,13 +2330,64 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingBulkWithProrationValidationWorks() + public void NewFloatingGroupedAllocationValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = + 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" } }, + }; + value.Validate(); + } + + [Fact] + public void NewFloatingBulkWithProrationValidationWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = new NewFloatingBulkWithProrationPrice() @@ -2078,6 +2430,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2128,6 +2481,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2191,6 +2545,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2596,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2653,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2350,6 +2707,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2403,6 +2761,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2433,6 +2792,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2463,6 +2823,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2526,6 +2887,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2582,6 +2944,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2632,21 +2995,86 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance() + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + 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(); } [Fact] - public void MinimumValidationWorks() + public void MeteredAllowanceValidationWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance() { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2675,6 +3103,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2723,6 +3152,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2766,6 +3196,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2815,6 +3246,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2858,6 +3290,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 +3353,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 +3404,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 +3464,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 +3515,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 +3571,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 +3631,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 +3691,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 +3762,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 +3822,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 +3893,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 +3950,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 +4002,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 +4063,86 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + 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 MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts() + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3671,6 +4196,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 +4248,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 +4305,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 +4362,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 +4420,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 +4491,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 +4549,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 +4613,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 +4674,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 +4735,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 +4773,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4268,6 +4804,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 +4875,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 +4939,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 +4997,69 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + 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 DailyCreditAllowanceSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance() + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4471,15 +5073,24 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance() { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4508,6 +5119,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); @@ -4563,6 +5175,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); @@ -4613,6 +5226,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 +5283,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 +5345,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4780,6 +5396,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 +5415,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +5472,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4913,6 +5532,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4971,6 +5591,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 +5613,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5048,6 +5670,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5095,6 +5718,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +5778,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5176,6 +5802,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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,21 +5838,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfig + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters + { + BulkWithFiltersConfig = new() { Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = @@ -5232,22 +5858,80 @@ public void FieldRoundtrip_Works() 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]); + }, + 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 + : TestBase +{ + [Fact] + public void FieldRoundtrip_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" }, + ], + }; + + 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++) @@ -5340,6 +6024,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 +6123,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 +6272,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 @@ -5731,26 +6467,47 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5779,26 +6536,46 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual; string expectedCurrency = "currency"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + string expectedItemID = "item_id"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -5809,7 +6586,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5829,15 +6606,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig ); - Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -5850,6 +6628,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5864,19 +6643,40 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5905,12 +6705,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -5922,19 +6723,40 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5963,12 +6785,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5976,21 +6799,40 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual; string expectedCurrency = "currency"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + string expectedItemID = "item_id"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "matrix_with_threshold_discounts" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6001,7 +6843,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6021,15 +6863,16 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig ); - Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -6045,6 +6888,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6059,20 +6903,41 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, ItemID = "item_id", - Name = "Annual fee", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6100,6 +6965,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6110,19 +6976,40 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -6146,6 +7033,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6154,19 +7043,40 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", }; @@ -6177,19 +7087,40 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -6202,6 +7133,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6225,6 +7157,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6233,19 +7167,40 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts { Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -6258,43 +7213,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadenceTest : TestBase { [Theory] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.SemiAnnual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Monthly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Quarterly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.OneTime )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Custom )] public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > value = rawValue; value.Validate(); } @@ -6305,7 +7337,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -6315,38 +7347,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.SemiAnnual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Monthly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Quarterly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.OneTime )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Custom )] public void SerializationRoundtrip_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > >(json, ModelBase.SerializerOptions); @@ -6359,14 +7391,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > >(json, ModelBase.SerializerOptions); @@ -6374,47 +7406,2624 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } } [Fact] public void SerializationRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig 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() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCurrency, model.Currency); + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCurrency, deserialized.Currency); + 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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + 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 + : TestBase +{ + [Theory] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom + )] + public void Validation_Works( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom + )] + public void SerializationRoundtrip_Works( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + 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 + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedCurrency, model.Currency); + 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); + Assert.Equal(expectedCurrency, deserialized.Currency); + 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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 + )] + [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() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom + )] + public void SerializationRoundtrip_Works( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + 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); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + 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 ); @@ -6426,56 +10035,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6487,7 +10114,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6508,7 +10135,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6516,7 +10143,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6527,7 +10154,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6544,7 +10171,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6553,75 +10180,74 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationTest - : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = 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 = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6631,7 +10257,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6651,14 +10277,12 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -6672,6 +10296,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6685,54 +10310,55 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6743,54 +10369,55 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6798,22 +10425,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6823,7 +10449,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6843,14 +10469,12 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); + Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -6867,6 +10491,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6880,50 +10505,51 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; model.Validate(); } @@ -6931,22 +10557,22 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - }; + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -6968,6 +10594,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6975,22 +10603,22 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - }; + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -6998,34 +10626,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ItemID = "item_id", + 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, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -7047,6 +10676,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7054,69 +10685,126 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - Cadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance copied = new( + model + ); - model.Validate(); + Assert.Equal(model, copied); } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceTest : TestBase { [Theory] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom )] public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > value = rawValue; value.Validate(); } @@ -7127,7 +10815,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -7137,38 +10825,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -7181,14 +10869,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -7196,29 +10884,171 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -7226,17 +11056,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7248,30 +11076,28 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -7279,25 +11105,39 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7309,7 +11149,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7330,7 +11170,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7338,7 +11178,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7349,7 +11189,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7366,7 +11206,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7375,17 +11215,26 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumTest : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7414,19 +11263,28 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7436,7 +11294,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7456,12 +11314,13 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -7474,6 +11333,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7487,12 +11347,21 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7521,12 +11390,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7537,12 +11407,21 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7571,12 +11450,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7584,14 +11464,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7601,7 +11489,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7621,12 +11509,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -7642,6 +11531,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7655,12 +11545,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7689,6 +11588,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7698,12 +11598,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -7727,6 +11636,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7734,12 +11645,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -7749,12 +11669,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -7767,6 +11696,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7790,6 +11720,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7797,12 +11729,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -7815,29 +11756,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; - model.Validate(); + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceTest : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadenceTest + : TestBase { [Theory] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom)] + [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual)] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime + )] + [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom)] public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > value = rawValue; value.Validate(); } @@ -7845,7 +11853,10 @@ PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -7853,23 +11864,36 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom)] + [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual)] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime + )] + [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom)] public void SerializationRoundtrip_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -7879,47 +11903,72 @@ PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigTest : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7930,35 +11979,53 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; model.Validate(); } @@ -7966,22 +12033,32 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } @@ -7989,40 +12066,72 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8034,7 +12143,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8055,7 +12164,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8063,7 +12172,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8074,7 +12183,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8091,7 +12200,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8139,6 +12248,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8181,6 +12291,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 +12310,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12358,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8296,6 +12409,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8346,6 +12460,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 +12482,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12530,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8452,6 +12569,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +12611,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8515,6 +12635,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +12662,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 +12848,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 +12993,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8856,6 +13041,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 +13060,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +13113,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8981,6 +13169,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9036,6 +13225,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 +13247,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +13300,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9152,6 +13344,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +13396,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9225,6 +13420,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +13452,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 +13728,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..e3eecfa06 100644 --- a/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs @@ -22,6 +22,16 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id"), url); + Assert.True(TestBase.UrisEqual(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..0d7e60eac 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() @@ -82,6 +83,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -129,6 +131,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 +190,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -202,6 +211,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -249,6 +259,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 +334,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -338,6 +355,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -385,6 +403,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 +476,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -472,6 +497,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -519,6 +545,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 +611,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -599,6 +632,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -646,6 +680,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 +755,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -735,6 +776,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -782,6 +824,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 +837,142 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..5b00dceec 100644 --- a/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs @@ -71,6 +71,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices?cursor=cursor&limit=1"), url); + Assert.True( + TestBase.UrisEqual( + 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..32fe477a2 100644 --- a/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs @@ -59,6 +59,20 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id"), url); + Assert.True(TestBase.UrisEqual(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..848d0f6c8 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() @@ -428,6 +430,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -475,6 +478,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 +564,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -575,6 +585,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -622,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() @@ -896,6 +917,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -923,6 +945,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -977,6 +1000,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 +1361,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1359,6 +1389,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1413,6 +1444,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 +1669,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1909,6 +1947,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1929,6 +1968,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1976,6 +2016,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 +2100,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2074,6 +2121,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2121,9 +2169,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 +2448,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2412,6 +2471,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2459,6 +2519,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 +2872,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2828,6 +2895,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2875,6 +2943,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 +3230,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3433,6 +3508,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3453,6 +3529,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3500,6 +3577,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 +3663,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3600,6 +3684,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3647,9 +3732,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 +4016,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3948,6 +4044,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4002,6 +4099,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 +4460,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4384,6 +4488,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4438,6 +4543,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 +4778,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -4944,6 +5056,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4964,6 +5077,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5011,6 +5125,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 +5211,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5111,6 +5232,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5158,9 +5280,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 +5564,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5459,6 +5592,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5513,6 +5647,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 +6008,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5895,6 +6036,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5949,6 +6091,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 +6323,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6452,6 +6601,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6472,6 +6622,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6519,6 +6670,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 +6754,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6617,6 +6775,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6664,9 +6823,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 +7102,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6955,6 +7125,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7002,6 +7173,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 +7526,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7371,6 +7549,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7418,6 +7597,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 +7893,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -7985,6 +8171,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8005,6 +8192,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8052,6 +8240,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 +8326,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8152,6 +8347,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8199,9 +8395,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 +8679,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8500,6 +8707,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8554,6 +8762,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 +9123,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8936,6 +9151,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8990,6 +9206,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 +9435,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9490,6 +9713,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9510,6 +9734,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9557,6 +9782,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 +9868,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9657,6 +9889,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9704,9 +9937,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 +10086,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -10120,6 +10364,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10140,6 +10385,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10187,6 +10433,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 +10519,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10287,6 +10540,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10334,9 +10588,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 +10736,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -10749,6 +11014,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10769,6 +11035,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10816,6 +11083,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 +11169,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10916,6 +11190,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10963,9 +11238,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 +11389,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11381,6 +11667,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11401,6 +11688,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11448,6 +11736,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 +11822,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11548,6 +11843,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11595,9 +11891,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 +11921,1550 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..4c8594b1b 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs @@ -97,9 +97,32 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscription_changes/subscription_change_id/apply"), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscription_changes/subscription_change_id/apply" + ), + 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..9c2bd00c9 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() @@ -441,6 +443,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -488,6 +491,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 +579,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -591,6 +601,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -638,9 +649,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 +948,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -954,6 +976,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1010,6 +1033,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 +1409,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1407,6 +1437,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1463,6 +1494,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 +1729,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2007,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1989,6 +2028,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2036,6 +2076,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 +2162,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2136,6 +2183,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2183,9 +2231,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 +2515,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2484,6 +2543,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2538,6 +2598,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 +2959,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2920,6 +2987,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2974,6 +3042,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 +3297,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3577,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3523,6 +3599,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3570,6 +3647,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 +3735,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3673,6 +3757,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3720,9 +3805,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 +4104,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4036,6 +4132,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4092,6 +4189,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 +4565,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4489,6 +4593,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4545,6 +4650,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 +4902,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5182,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5091,6 +5204,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5138,6 +5252,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 +5340,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5241,6 +5362,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5288,9 +5410,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 +5709,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5604,6 +5737,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5660,6 +5794,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 +6170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6057,6 +6198,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6113,6 +6255,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 +6497,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6775,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6646,6 +6796,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6693,6 +6844,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 +6930,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6793,6 +6951,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6840,9 +6999,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 +7283,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7141,6 +7311,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7195,6 +7366,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 +7727,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7577,6 +7755,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7631,6 +7810,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 +8065,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8345,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8180,6 +8367,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8227,6 +8415,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 +8503,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8330,6 +8525,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8377,9 +8573,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 +8872,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8693,6 +8900,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8749,6 +8957,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 +9333,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9146,6 +9361,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9202,6 +9418,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 +9664,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9944,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9742,6 +9966,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9789,6 +10014,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 +10102,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9892,6 +10124,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9939,9 +10172,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 +10471,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10255,6 +10499,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10311,6 +10556,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 +10932,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10708,6 +10960,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10764,6 +11017,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 +11268,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11548,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11309,6 +11570,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11356,6 +11618,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 +11706,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11459,6 +11728,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11506,9 +11776,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 +12075,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11822,6 +12103,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11878,6 +12160,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 +12536,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12275,6 +12564,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12331,6 +12621,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 +12861,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13141,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12865,6 +13163,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12912,6 +13211,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 +13299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13015,6 +13321,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13062,9 +13369,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 +13668,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13378,6 +13696,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13434,6 +13753,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 +14129,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13831,6 +14157,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13887,6 +14214,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 +14472,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14752,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14439,6 +14774,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14486,6 +14822,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 +14910,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14589,6 +14932,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14636,9 +14980,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 +15279,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14952,6 +15307,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15008,6 +15364,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 +15740,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15405,6 +15768,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15461,6 +15825,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 +15942,1607 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..f17401fc2 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscription_changes/subscription_change_id/cancel" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscription_changes/subscription_change_id/cancel" + ), + 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..7e6430491 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() @@ -441,6 +443,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -488,6 +491,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 +579,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -591,6 +601,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -638,9 +649,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 +948,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -954,6 +976,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1010,6 +1033,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 +1409,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1407,6 +1437,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1463,6 +1494,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 +1729,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2007,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1989,6 +2028,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2036,6 +2076,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 +2162,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2136,6 +2183,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2183,9 +2231,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 +2515,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2484,6 +2543,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2538,6 +2598,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 +2959,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2920,6 +2987,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2974,6 +3042,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 +3297,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3577,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3523,6 +3599,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3570,6 +3647,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 +3735,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3673,6 +3757,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3720,9 +3805,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 +4104,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4036,6 +4132,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4092,6 +4189,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 +4565,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4489,6 +4593,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4545,6 +4650,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 +4902,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5182,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5091,6 +5204,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5138,6 +5252,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 +5340,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5241,6 +5362,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5288,9 +5410,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 +5709,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5604,6 +5737,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5660,6 +5794,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 +6170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6057,6 +6198,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6113,6 +6255,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 +6497,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6775,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6646,6 +6796,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6693,6 +6844,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 +6930,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6793,6 +6951,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6840,9 +6999,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 +7283,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7141,6 +7311,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7195,6 +7366,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 +7727,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7577,6 +7755,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7631,6 +7810,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 +8065,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8345,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8180,6 +8367,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8227,6 +8415,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 +8503,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8330,6 +8525,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8377,9 +8573,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 +8872,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8693,6 +8900,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8749,6 +8957,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 +9333,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9146,6 +9361,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9202,6 +9418,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 +9664,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9944,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9742,6 +9966,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9789,6 +10014,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 +10102,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9892,6 +10124,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9939,9 +10172,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 +10471,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10255,6 +10499,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10311,6 +10556,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 +10932,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10708,6 +10960,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10764,6 +11017,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 +11268,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11548,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11309,6 +11570,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11356,6 +11618,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 +11706,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11459,6 +11728,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11506,9 +11776,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 +12075,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11822,6 +12103,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11878,6 +12160,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 +12536,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12275,6 +12564,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12331,6 +12621,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 +12861,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13141,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12865,6 +13163,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12912,6 +13211,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 +13299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13015,6 +13321,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13062,9 +13369,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 +13668,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13378,6 +13696,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13434,6 +13753,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 +14129,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13831,6 +14157,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13887,6 +14214,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 +14472,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14752,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14439,6 +14774,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14486,6 +14822,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 +14910,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14589,6 +14932,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14636,9 +14980,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 +15279,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14952,6 +15307,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15008,6 +15364,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 +15740,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15405,6 +15768,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15461,6 +15825,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 +15942,1607 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..072897646 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs @@ -118,13 +118,32 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscription_changes?cursor=cursor&customer_id=customer_id&external_customer_id=external_customer_id&limit=1&status=pending" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscription_changes?cursor=cursor&customer_id=customer_id&external_customer_id=external_customer_id&limit=1&status=pending" + ), + 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..334d747a6 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs @@ -28,9 +28,24 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscription_changes/subscription_change_id"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscription_changes/subscription_change_id"), + 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..11cb4a9cf 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() @@ -441,6 +443,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -488,6 +491,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 +579,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -591,6 +601,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -638,9 +649,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 +948,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -954,6 +976,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1010,6 +1033,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 +1409,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1407,6 +1437,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1463,6 +1494,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 +1729,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2007,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1989,6 +2028,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2036,6 +2076,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 +2162,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2136,6 +2183,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2183,9 +2231,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 +2515,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2484,6 +2543,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2538,6 +2598,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 +2959,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2920,6 +2987,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2974,6 +3042,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 +3297,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3577,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3523,6 +3599,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3570,6 +3647,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 +3735,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3673,6 +3757,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3720,9 +3805,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 +4104,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4036,6 +4132,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4092,6 +4189,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 +4565,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4489,6 +4593,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -4545,6 +4650,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 +4902,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5182,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5091,6 +5204,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5138,6 +5252,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 +5340,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5241,6 +5362,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5288,9 +5410,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 +5709,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5604,6 +5737,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -5660,6 +5794,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 +6170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6057,6 +6198,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6113,6 +6255,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 +6497,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6775,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6646,6 +6796,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6693,6 +6844,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 +6930,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6793,6 +6951,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -6840,9 +6999,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 +7283,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7141,6 +7311,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7195,6 +7366,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 +7727,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7577,6 +7755,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -7631,6 +7810,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 +8065,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8345,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8180,6 +8367,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8227,6 +8415,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 +8503,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8330,6 +8525,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8377,9 +8573,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 +8872,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8693,6 +8900,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -8749,6 +8957,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 +9333,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9146,6 +9361,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9202,6 +9418,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 +9664,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9944,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9742,6 +9966,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9789,6 +10014,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 +10102,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9892,6 +10124,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -9939,9 +10172,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 +10471,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10255,6 +10499,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10311,6 +10556,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 +10932,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10708,6 +10960,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -10764,6 +11017,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 +11268,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11548,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11309,6 +11570,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11356,6 +11618,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 +11706,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11459,6 +11728,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11506,9 +11776,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 +12075,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11822,6 +12103,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -11878,6 +12160,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 +12536,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12275,6 +12564,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12331,6 +12621,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 +12861,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13141,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12865,6 +13163,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -12912,6 +13211,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 +13299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13015,6 +13321,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13062,9 +13369,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 +13668,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13378,6 +13696,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13434,6 +13753,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 +14129,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13831,6 +14157,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -13887,6 +14214,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 +14472,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14752,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14439,6 +14774,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14486,6 +14822,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 +14910,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14589,6 +14932,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -14636,9 +14980,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 +15279,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14952,6 +15307,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15008,6 +15364,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 +15740,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15405,6 +15768,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -15461,6 +15825,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 +15942,1607 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..138d37974 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs @@ -74,11 +74,29 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/cancel"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/cancel"), + 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..2bb5c2dfa 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -69,6 +69,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -84,6 +86,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 +128,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -216,6 +223,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -231,6 +240,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 +281,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -333,6 +347,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -348,6 +364,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 +405,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -480,6 +501,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -495,6 +518,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 +558,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -693,6 +721,8 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -708,6 +738,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 +780,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -839,6 +874,8 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -854,6 +891,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 +932,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -967,6 +1009,8 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -982,6 +1026,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 +1068,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1113,6 +1162,8 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1128,6 +1179,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 +1220,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1373,248 +1429,302 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions"), url); + Assert.True(TestBase.UrisEqual(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"], - }, - ], - 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() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::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() + 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"), - }; - - 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 = + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AddPrices = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - 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", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + 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"), + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"], }; - 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")); + Subscriptions::SubscriptionCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); } +} +public class AddAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtrip_Works() { var model = new Subscriptions::AddAdjustment { @@ -1638,14 +1748,44 @@ 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() - { + 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, 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() @@ -1668,22 +1808,22 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() IsInvoiceLevel = true, PriceType = NewPercentageDiscountPriceType.Usage, }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, + 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.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")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = new Subscriptions::AddAdjustment { @@ -1707,22 +1847,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() IsInvoiceLevel = true, PriceType = NewPercentageDiscountPriceType.Usage, }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - model.Validate(); - } -} + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); -public class AdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - Subscriptions::Adjustment value = new NewPercentageDiscount() + Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, PercentageDiscount = 0, @@ -1742,118 +1879,360 @@ public void NewPercentageDiscountValidationWorks() 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"); - [Fact] - public void NewUsageDiscountValidationWorks() - { - Subscriptions::Adjustment value = new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void NewAmountDiscountValidationWorks() + public void Validation_Works() { - Subscriptions::Adjustment value = new NewAmountDiscount() + var model = new Subscriptions::AddAdjustment { - 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, + 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"), }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::Adjustment value = new NewMinimum() + var model = new Subscriptions::AddAdjustment { - 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, + 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, + }, }; - value.Validate(); + + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewMaximumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::Adjustment value = new NewMaximum() + var model = new Subscriptions::AddAdjustment { - 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, + 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, + }, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::Adjustment value = new NewPercentageDiscount() + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + model.Validate(); + } + + [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 +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + Subscriptions::Adjustment value = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewUsageDiscountValidationWorks() + { + Subscriptions::Adjustment value = new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewAmountDiscountValidationWorks() + { + Subscriptions::Adjustment value = new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMinimumValidationWorks() + { + Subscriptions::Adjustment value = new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMaximumValidationWorks() + { + Subscriptions::Adjustment value = new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewPercentageDiscountSerializationRoundtripWorks() + { + Subscriptions::Adjustment value = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, PercentageDiscount = 0, @@ -2040,6 +2419,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2055,6 +2436,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 +2477,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2120,6 +2506,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2135,6 +2523,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 +2564,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2188,6 +2581,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 +2622,8 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2236,6 +2639,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 +2680,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2315,6 +2723,8 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2330,6 +2740,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 +2781,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2402,6 +2817,8 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2417,7 +2834,11 @@ public void FieldRoundtripThroughSerialization_Works() DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string expectedExternalPriceID = "external_price_id"; string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedMinimumAmount = "1.23"; long expectedPlanPhaseOrder = 0; Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() { @@ -2454,6 +2875,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2470,6 +2892,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 +2938,8 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2518,6 +2955,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 +2996,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2580,6 +3022,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 +3054,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2627,6 +3072,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 +3096,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2658,6 +3106,103 @@ 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", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 +3245,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2756,6 +3302,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2800,6 +3347,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2851,6 +3399,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2895,6 +3444,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2944,6 +3494,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2997,6 +3548,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3049,6 +3601,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3113,6 +3666,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3165,6 +3719,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3229,6 +3784,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3279,6 +3835,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3323,6 +3880,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3374,6 +3932,76 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Subscriptions::Price value = new Subscriptions::MatrixWithThresholdDiscounts() + { + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3419,6 +4047,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3464,6 +4093,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3514,6 +4144,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3564,6 +4195,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3616,6 +4248,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3681,6 +4314,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3730,6 +4364,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3787,6 +4422,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3841,6 +4477,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3895,6 +4532,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3926,6 +4564,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3957,6 +4596,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4022,6 +4662,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4079,6 +4720,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4128,6 +4770,58 @@ 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 DailyCreditAllowanceValidationWorks() + { + Subscriptions::Price value = new Subscriptions::DailyCreditAllowance() + { + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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", }; @@ -4135,13 +4829,21 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void MeteredAllowanceValidationWorks() { - Subscriptions::Price value = new Subscriptions::Minimum() + Subscriptions::Price value = new Subscriptions::MeteredAllowance() { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4171,6 +4873,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4216,6 +4919,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4259,6 +4963,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4307,6 +5012,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4351,6 +5057,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4413,6 +5120,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4463,6 +5171,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4520,6 +5229,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4570,6 +5280,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4625,6 +5336,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4684,6 +5396,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4742,6 +5455,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4812,6 +5526,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4870,6 +5585,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4940,6 +5656,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4996,6 +5713,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5046,6 +5764,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5103,6 +5822,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5116,16 +5836,39 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::TieredWithProration() + Subscriptions::Price value = new Subscriptions::MatrixWithThresholdDiscounts() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5154,6 +5897,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5167,16 +5911,16 @@ public void TieredWithProrationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() + Subscriptions::Price value = new Subscriptions::TieredWithProration() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5205,6 +5949,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5218,21 +5963,16 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5261,6 +6001,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5274,9 +6015,66 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + { + Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() { BulkWithProrationConfig = new( [ @@ -5317,6 +6115,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5375,6 +6174,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5446,6 +6246,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5501,6 +6302,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5564,6 +6366,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5624,6 +6427,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5684,6 +6488,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5721,6 +6526,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -5752,6 +6558,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5823,6 +6630,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5886,6 +6694,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5941,6 +6750,64 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 DailyCreditAllowanceSerializationRoundtripWorks() + { + Subscriptions::Price value = new Subscriptions::DailyCreditAllowance() + { + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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", }; @@ -5954,13 +6821,21 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::Minimum() + Subscriptions::Price value = new Subscriptions::MeteredAllowance() { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5990,6 +6865,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6041,6 +6917,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6090,6 +6967,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6144,6 +7022,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6204,6 +7083,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6250,6 +7130,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 +7150,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +7207,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6383,6 +7266,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6436,6 +7320,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 +7343,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +7400,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6562,6 +7449,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +7508,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6645,6 +7535,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +7572,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 +7752,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 +7826,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 +7952,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 @@ -7121,19 +8111,42 @@ public void TieredSerializationRoundtripWorks() } } -public class TieredWithProrationTest : TestBase +public class MatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7162,18 +8175,45 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::MatrixWithThresholdDiscountsCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); - string expectedName = "Annual fee"; - Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + Subscriptions::MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" ); + string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -7182,7 +8222,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7203,14 +8243,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(expectedItemID, model.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); 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); @@ -7222,6 +8266,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7236,23 +8281,46 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -7272,12 +8340,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 ); @@ -7288,14 +8357,37 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7324,25 +8416,52 @@ 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::TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::MatrixWithThresholdDiscountsCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); - string expectedName = "Annual fee"; - Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + Subscriptions::MatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" ); + string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -7351,7 +8470,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7372,14 +8491,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(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); 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); @@ -7394,6 +8517,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7408,14 +8532,37 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7444,6 +8591,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7454,14 +8602,37 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -7486,6 +8657,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7495,14 +8668,37 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -7511,14 +8707,37 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7531,6 +8750,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7557,6 +8777,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7566,14 +8788,37 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::TieredWithProration + var model = new Subscriptions::MatrixWithThresholdDiscounts { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7586,27 +8831,100 @@ 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::MatrixWithThresholdDiscounts + { + Cadence = Subscriptions::MatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::MatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationCadenceTest : TestBase +public class MatrixWithThresholdDiscountsCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] - public void Validation_Works(Subscriptions::TieredWithProrationCadence rawValue) + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works(Subscriptions::MatrixWithThresholdDiscountsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -7614,7 +8932,7 @@ public void Validation_Works(Subscriptions::TieredWithProrationCadence rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -7622,20 +8940,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::TieredWithProrationCadence rawValue) + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::MatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::MatrixWithThresholdDiscountsCadence 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); @@ -7645,52 +8965,125 @@ public void SerializationRoundtrip_Works(Subscriptions::TieredWithProrationCaden 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 TieredWithProrationConfigTest : TestBase +public class MatrixWithThresholdDiscountsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - Assert.Equal(expectedTiers[i], model.Tiers[i]); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::TieredWithProrationConfig + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; 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); } @@ -7698,372 +9091,419 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::TieredWithProrationConfig + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - List expectedTiers = + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ]; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); } } [Fact] public void Validation_Works() { - var model = new Subscriptions::TieredWithProrationConfig + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; model.Validate(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::TieredWithProrationConfigTier + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::TieredWithProrationConfigTier + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - 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 OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Subscriptions::TieredWithProrationConfigTier + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void Validation_Works() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::TieredWithProrationConfigTier + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; model.Validate(); } -} -public class TieredWithProrationConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - [Fact] - public void TieredValidationWorks() - { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void UnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], - Assert.Equal(value, deserialized); + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); } -} -public class GroupedWithMinMaxThresholdsTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], - ApiEnum expectedCadence = - Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + SecondDimension = null, }; - double expectedConversionRate = 0; - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MatrixWithThresholdDiscountsConfig { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + + Subscriptions::MatrixWithThresholdDiscountsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::MatrixValue { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8074,182 +9514,37 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] public void Validation_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; model.Validate(); @@ -8258,63 +9553,23 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + FirstDimensionValue = "first_dimension_value", + 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.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; model.Validate(); @@ -8323,257 +9578,241 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + FirstDimensionValue = "first_dimension_value", + 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, + SecondDimensionValue = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + var model = new Subscriptions::MatrixValue { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + FirstDimensionValue = "first_dimension_value", + 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, + SecondDimensionValue = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::MatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + Subscriptions::MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ThresholdDiscountGroupTest : TestBase { - [Theory] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue) + [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::ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = new Subscriptions::ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; - 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::GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue - ) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new Subscriptions::ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new Subscriptions::ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; - Assert.Equal(value, deserialized); + model.Validate(); } -} -public class GroupedWithMinMaxThresholdsConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + var model = new Subscriptions::ThresholdDiscountGroup { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - 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); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + var model = new Subscriptions::ThresholdDiscountGroup { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - 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 Subscriptions::GroupedWithMinMaxThresholdsConfig + var model = new Subscriptions::ThresholdDiscountGroup { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::ThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Description = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + var model = new Subscriptions::ThresholdDiscountGroup { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - model.Validate(); + Subscriptions::ThresholdDiscountGroup copied = new(model); + + Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class MatrixWithThresholdDiscountsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8585,7 +9824,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8606,7 +9845,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8614,7 +9853,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8625,7 +9864,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::MatrixWithThresholdDiscountsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8642,7 +9881,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8651,23 +9890,19 @@ public void TieredSerializationRoundtripWorks() } } -public class CumulativeGroupedAllocationTest : TestBase +public class TieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -8696,25 +9931,19 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::CumulativeGroupedAllocationCadence.Annual; - Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = + Subscriptions::TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8723,7 +9952,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8744,17 +9973,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); @@ -8766,6 +9993,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8780,18 +10008,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -8820,12 +10044,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 ); @@ -8836,18 +10061,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -8876,32 +10097,26 @@ 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::CumulativeGroupedAllocationCadence.Annual; - Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = + Subscriptions::TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8910,7 +10125,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8931,17 +10146,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); @@ -8956,6 +10169,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8970,18 +10184,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -9010,6 +10220,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9020,18 +10231,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -9056,6 +10263,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9065,18 +10274,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -9085,18 +10290,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9109,6 +10310,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9135,6 +10337,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9144,18 +10348,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9168,27 +10368,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 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 CumulativeGroupedAllocationCadenceTest : TestBase +public class TieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(Subscriptions::CumulativeGroupedAllocationCadence rawValue) + [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] + public void Validation_Works(Subscriptions::TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -9196,7 +10446,7 @@ public void Validation_Works(Subscriptions::CumulativeGroupedAllocationCadence r public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -9204,22 +10454,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::CumulativeGroupedAllocationCadence rawValue - ) + [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -9229,58 +10477,52 @@ 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 CumulativeGroupedAllocationConfigTest : TestBase +public class TieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::TieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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::CumulativeGroupedAllocationConfig + var model = new Subscriptions::TieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + 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); } @@ -9288,54 +10530,147 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::TieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + 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 expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - } + 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::CumulativeGroupedAllocationConfig + var model = new Subscriptions::TieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::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 Subscriptions::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 Subscriptions::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 Subscriptions::TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class TieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::TieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9347,7 +10682,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9368,7 +10703,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::TieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9376,7 +10711,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9387,7 +10722,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::TieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9404,7 +10739,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9413,16 +10748,22 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9452,19 +10793,25 @@ 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::GroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig 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; @@ -9474,7 +10821,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9495,12 +10842,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); @@ -9514,6 +10865,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,11 +10880,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9562,12 +10920,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,11 +10937,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9612,26 +10977,32 @@ 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::GroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig 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; @@ -9641,7 +11012,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9662,12 +11033,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); @@ -9684,6 +11059,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,11 +11074,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9732,6 +11114,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9742,11 +11125,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9772,6 +11161,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,11 +11172,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9795,11 +11192,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9813,6 +11216,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9839,6 +11243,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,11 +11254,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9866,57 +11278,112 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class MinimumCadenceTest : 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) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [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::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) + public void CopyConstructor_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - + 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 +{ + [Theory] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -9925,51 +11392,59 @@ public void SerializationRoundtrip_Works(Subscriptions::MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class MinimumConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig { - 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::MinimumConfig + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig { - 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( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -9977,131 +11452,114 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig { - 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + 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::MinimumConfig + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig { - 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::MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::GroupedWithMinMaxThresholdsConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class MinimumConversionRateConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -10109,41 +11567,49 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class PercentTest : TestBase +public class CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10172,16 +11638,26 @@ 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::CumulativeGroupedAllocationCadence.Annual; + Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10190,7 +11666,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10211,14 +11687,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); @@ -10230,6 +11710,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11725,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10278,12 +11765,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 +11782,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10328,23 +11822,33 @@ 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::CumulativeGroupedAllocationCadence.Annual; + Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10353,7 +11857,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10374,14 +11878,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); @@ -10396,6 +11904,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11919,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10444,6 +11959,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10454,12 +11970,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10484,6 +12006,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12017,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -10507,12 +12037,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10525,6 +12061,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10551,6 +12088,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12099,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10578,57 +12123,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 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 PercentCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : 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::CumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(Subscriptions::CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(Subscriptions::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::CumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::CumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -10637,41 +12237,59 @@ public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PercentConfigTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::CumulativeGroupedAllocationConfig + { + 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::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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 - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -10679,75 +12297,114 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; 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 PercentConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -10755,43 +12412,47 @@ 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::CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class EventOutputTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -10823,20 +12484,23 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = + Subscriptions::DailyCreditAllowanceCadence.Annual; + Subscriptions::DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -10846,7 +12510,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10867,11 +12531,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -10886,6 +12551,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10900,14 +12566,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -10939,12 +12607,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 ); @@ -10955,14 +12624,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -10994,27 +12665,30 @@ 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::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = + Subscriptions::DailyCreditAllowanceCadence.Annual; + Subscriptions::DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -11024,7 +12698,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11045,11 +12719,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -11067,6 +12742,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -11081,14 +12757,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -11120,6 +12798,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11130,14 +12809,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -11165,6 +12846,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11174,14 +12857,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -11193,14 +12878,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -11216,6 +12903,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11242,6 +12930,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -11251,14 +12941,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -11274,57 +12966,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 Subscriptions::DailyCreditAllowance + { + Cadence = Subscriptions::DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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::DailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class EventOutputCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void Validation_Works(Subscriptions::EventOutputCadence rawValue) + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Custom)] + public void Validation_Works(Subscriptions::DailyCreditAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawValue) + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::DailyCreditAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::DailyCreditAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -11333,52 +13079,70 @@ public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawVa [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class EventOutputConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11389,111 +13153,194 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } } [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + var model = new Subscriptions::DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); + Subscriptions::DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class DailyCreditAllowanceConfigMatrixValueTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + var model = new Subscriptions::DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; - model.Validate(); + List expectedDimensionValues = ["string"]; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfigMatrixValue { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::DailyCreditAllowanceConfigMatrixValue { - UnitRatingKey = "x", + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; - DefaultUnitRate = null, - GroupingKey = null, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedDimensionValues = ["string"]; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::DailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; model.Validate(); } -} -public class EventOutputConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + var model = new Subscriptions::DailyCreditAllowanceConfigMatrixValue { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; - value.Validate(); + + Subscriptions::DailyCreditAllowanceConfigMatrixValue copied = new(model); + + Assert.Equal(model, copied); } +} +public class DailyCreditAllowanceConversionRateConfigTest : TestBase +{ [Fact] - public void TieredValidationWorks() + public void UnitValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::DailyCreditAllowanceConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::DailyCreditAllowanceConversionRateConfig value = + new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -11513,14 +13360,15 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::DailyCreditAllowanceConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11531,7 +13379,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::EventOutputConversionRateConfig value = + Subscriptions::DailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11548,7 +13396,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11557,83 +13405,185 @@ public void TieredSerializationRoundtripWorks() } } -public class ExternalMarketplaceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void Validation_Works(Subscriptions::ExternalMarketplace rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class RemoveAdjustmentTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + var model = new Subscriptions::MeteredAllowance + { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 expectedAdjustmentID = "h74gfhdjvn7ujokd"; + ApiEnum expectedCadence = + Subscriptions::MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::MeteredAllowanceConversionRateConfig 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"; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.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::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + var model = new Subscriptions::MeteredAllowance + { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11644,95 +13594,186 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - model.Validate(); - } -} - -public class RemovePriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::RemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::RemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::RemovePrice + var model = new Subscriptions::MeteredAllowance { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + ApiEnum expectedCadence = + Subscriptions::MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::MeteredAllowanceConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.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::RemovePrice + var model = new Subscriptions::MeteredAllowance { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = 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", }; model.Validate(); @@ -11741,18 +13782,70 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::RemovePrice { }; + var model = new Subscriptions::MeteredAllowance + { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); Assert.Null(model.ExternalPriceID); Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::RemovePrice { }; + var model = new Subscriptions::MeteredAllowance + { + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; model.Validate(); } @@ -11760,109 +13853,267 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; - - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::MeteredAllowance { - Adjustment = new NewPercentageDiscount() + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ReplacesAdjustmentID = "replaces_adjustment_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, }; - Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::MeteredAllowance { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + 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 expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::MeteredAllowance { - Adjustment = new NewPercentageDiscount() + Cadence = Subscriptions::MeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ReplacesAdjustmentID = "replaces_adjustment_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::MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MeteredAllowanceCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::MeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::MeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::MeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Custom)] + public void Validation_Works(Subscriptions::MeteredAllowanceCadence rawValue) + { + // force 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::MeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::MeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::MeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::MeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::MeteredAllowanceCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class MeteredAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11873,965 +14124,603 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::MeteredAllowanceConfig { - 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", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::MeteredAllowanceConfig { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::MeteredAllowanceConfig { - 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", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - model.Validate(); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } -} -public class ReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + var model = new Subscriptions::MeteredAllowanceConfig { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewUsageDiscountValidationWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + var model = new Subscriptions::MeteredAllowanceConfig { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - value.Validate(); + + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] - public void NewAmountDiscountValidationWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + var model = new Subscriptions::MeteredAllowanceConfig { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewMinimumValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + var model = new Subscriptions::MeteredAllowanceConfig { - 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, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; + + Subscriptions::MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MeteredAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::MeteredAllowanceConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void TieredValidationWorks() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; + Subscriptions::MeteredAllowanceConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - 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, - }; + Subscriptions::MeteredAllowanceConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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 - ); + Subscriptions::MeteredAllowanceConversionRateConfig 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 PercentTest : TestBase +{ [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + var model = new Subscriptions::Percent { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.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", }; - 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() + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + Subscriptions::PercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - 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, + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + double expectedConversionRate = 0; + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + 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"; - Assert.Equal(value, deserialized); + 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 NewMaximumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + var model = new Subscriptions::Percent { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.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", }; - 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); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::Percent { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = 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", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - PriceID = "h74gfhdjvn7ujokd", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + Subscriptions::PercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - 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", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; - 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() + double expectedConversionRate = 0; + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string expectedPriceID = "h74gfhdjvn7ujokd"; + 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"; - 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(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.Equal(expectedDiscounts[i], model.Discounts[i]); + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); } - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::Percent { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = 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", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - PriceID = "h74gfhdjvn7ujokd", + LicenseTypeID = "license_type_id", + Metadata = new 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::ReplacePrice + var model = new Subscriptions::Percent { - 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", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::Percent { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Name = "Annual fee", + PercentConfig = new(0), }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::ReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(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(); } @@ -12839,71 +14728,97 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::Percent { - ReplacesPriceID = "replaces_price_id", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), - AllocationPrice = null, - Discounts = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, ExternalPriceID = null, FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); Assert.Null(model.ExternalPriceID); Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.FixedPriceQuantity); Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::Percent { - ReplacesPriceID = "replaces_price_id", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), - AllocationPrice = null, - Discounts = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, ExternalPriceID = null, FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); } -} -public class ReplacePricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + var model = new Subscriptions::Percent { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12932,24 +14847,163 @@ public void NewSubscriptionUnitValidationWorks() 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 PercentCadenceTest : 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) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void InvalidEnumValidationThrows_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::PercentCadence.Annual)] + [InlineData(Subscriptions::PercentCadence.SemiAnnual)] + [InlineData(Subscriptions::PercentCadence.Monthly)] + [InlineData(Subscriptions::PercentCadence.Quarterly)] + [InlineData(Subscriptions::PercentCadence.OneTime)] + [InlineData(Subscriptions::PercentCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(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 PercentConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::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 Subscriptions::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 Subscriptions::PercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + Subscriptions::PercentConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ new() { @@ -12957,52 +15011,71 @@ public void NewSubscriptionTieredValidationWorks() UnitAmount = "unit_amount", LastUnit = 0, }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ] + ), }; value.Validate(); } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + 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::PercentConversionRateConfig 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 EventOutputTest : 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", - ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13032,74 +15105,97 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); - } - [Fact] - public void BulkWithFiltersValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() + 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() { - BulkWithFiltersConfig = new() - { - 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", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - value.Validate(); + 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"; + + 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 NewSubscriptionPackageValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, 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() @@ -13128,26 +15224,33 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = 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 NewSubscriptionMatrixValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::EventOutput { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13177,1225 +15280,7430 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = 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 = + 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, + }; + 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 NewSubscriptionThresholdTotalAmountValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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(); + 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", + }; + + model.Validate(); } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 NewSubscriptionTieredWithMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::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, + 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 EventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::EventOutputCadence.Annual)] + [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] + [InlineData(Subscriptions::EventOutputCadence.Monthly)] + [InlineData(Subscriptions::EventOutputCadence.Quarterly)] + [InlineData(Subscriptions::EventOutputCadence.OneTime)] + [InlineData(Subscriptions::EventOutputCadence.Custom)] + public void Validation_Works(Subscriptions::EventOutputCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::EventOutputCadence.Annual)] + [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] + [InlineData(Subscriptions::EventOutputCadence.Monthly)] + [InlineData(Subscriptions::EventOutputCadence.Quarterly)] + [InlineData(Subscriptions::EventOutputCadence.OneTime)] + [InlineData(Subscriptions::EventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class EventOutputConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::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 EventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + 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 ExternalMarketplaceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void Validation_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + model.Validate(); + } + + [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 + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedPriceID, deserialized.PriceID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::RemovePrice { }; + + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::RemovePrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::RemovePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string json = 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() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + Subscriptions::ReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + 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() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + 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() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + 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() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMaximumValidationWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewPercentageDiscountSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + 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::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMaximumSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ReplacePriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; + + 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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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::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(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 SerializationRoundtrip_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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; + + string json = 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::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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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::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(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 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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; + + 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 + { + 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::ReplacePrice + { + 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 CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; + + Subscriptions::ReplacePrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionBulkValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceBulkWithFilters() + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionThresholdTotalAmountValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + { + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredWithMinimumValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedTieredValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionPackageWithAllocationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitWithPercentValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixWithAllocationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts() + { + Cadence = + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceTieredWithProration() + { + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitWithProrationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedAllocationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionBulkWithProrationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() + { + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedTieredPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + { + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + { + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceDailyCreditAllowance() + { + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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(); + } + + [Fact] + public void MeteredAllowanceValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceMeteredAllowance() + { + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionMinimumCompositeValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() + { + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void PercentValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionTieredSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionBulkSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() + { + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceBulkWithFilters() + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionPackageSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionMatrixSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + { + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts() + { + Cadence = + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 TieredWithProrationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceTieredWithProration() + { + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() + { + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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 + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + { + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + { + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void DailyCreditAllowanceSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceDailyCreditAllowance() + { + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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); + } + + [Fact] + public void MeteredAllowanceSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceMeteredAllowance() + { + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() + { + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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, + }, + LicenseTypeID = "license_type_id", + 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, + }; + 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 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", + }; + + string json = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = 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, + }; + 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 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", + }; + + 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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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, + 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 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(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::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 NewSubscriptionUnitWithPercentValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::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 NewSubscriptionMatrixWithAllocationValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); } [Fact] - public void TieredWithProrationValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceTieredWithProration() - { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new( + model + ); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 NewSubscriptionGroupedAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 NewSubscriptionBulkWithProrationValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() - { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() - { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); } +} - [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() +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) { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void InvalidEnumValidationThrows_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + [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 + ) { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() - { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid 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() + { + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void TieredValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ 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", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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() + public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = + 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::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ new() { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, UnitAmount = "unit_amount", + LastUnit = 0, }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ] + ), }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsTest : TestBase +{ [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::ReplacePricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - value.Validate(); + 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"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.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() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceMinimum() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14425,71 +22733,55 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); - } - [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() - { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void PercentValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePricePercent() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::ReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14518,25 +22810,156 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = 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< + string, + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.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() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14566,84 +22989,288 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::ReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() + var model = new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - Prorated = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14672,1796 +23299,1053 @@ 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); + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works( + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() - { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest + : TestBase +{ [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - Metadata = new 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.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { 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() + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = 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::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, - Metadata = new 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.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - 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", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceTieredWithProration() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage ); - - Assert.Equal(value, deserialized); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - 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() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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 - ); + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; - Assert.Equal(value, deserialized); + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void CopyConstructor_Works() { - 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() + var model = + new Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceBulkWithFiltersTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::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() @@ -16490,25 +24374,20 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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; + ApiEnum< + string, + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -16517,7 +24396,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16538,14 +24417,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); @@ -16557,6 +24437,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16571,20 +24452,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::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() @@ -16613,13 +24488,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 ); @@ -16630,20 +24506,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::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() @@ -16672,33 +24542,28 @@ 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::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; + ApiEnum< + string, + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -16707,7 +24572,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16728,14 +24593,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); @@ -16750,6 +24616,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -16764,20 +24631,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::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() @@ -16806,6 +24667,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16816,20 +24678,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -16854,6 +24710,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -16863,20 +24721,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -16885,20 +24737,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -16911,6 +24757,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16936,274 +24783,197 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.Null(model.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]); - } + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - 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::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(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - PropertyKey = "x", - PropertyValue = "x", + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + Subscriptions::ReplacePricePriceTieredWithProration copied = new(model); - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works( + Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue + ) { - 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); + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + [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 + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + 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::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + var value = 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + 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::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 ); @@ -17214,160 +24984,158 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 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")); - } + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) { - UnitAmount = "unit_amount", - }; - - model.Validate(); + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - model.Validate(); + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = new( + model + ); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : 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) + [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::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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - 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::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 - ) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + 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 ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17379,7 +25147,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17400,7 +25168,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17408,7 +25176,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17419,7 +25187,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17436,7 +25204,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17445,19 +25213,23 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +25258,29 @@ 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::ReplacePricePriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +25289,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17528,14 +25310,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( + 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); @@ -17547,6 +25333,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25348,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +25388,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 +25406,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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,13 +25446,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 ); @@ -17664,13 +25461,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceTieredWithProrationCadence - > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +25485,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17700,14 +25506,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( + 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); @@ -17722,6 +25532,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25547,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +25587,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17782,14 +25598,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -17814,6 +25634,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25645,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -17839,14 +25665,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -17859,6 +25689,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17885,6 +25716,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25727,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -17914,29 +25751,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 ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : 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)] + [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::ReplacePricePriceTieredWithProrationCadence rawValue + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -17945,7 +25836,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -17953,23 +25844,23 @@ public void InvalidEnumValidationThrows_Works() } [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)] + [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::ReplacePricePriceTieredWithProrationCadence 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); @@ -17979,129 +25870,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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - model.Validate(); - } -} - -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + 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 ); @@ -18113,47 +25933,73 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + 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 expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + GroupingKey = "x", + 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 ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18165,7 +26011,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18186,7 +26032,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18194,7 +26040,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18205,7 +26051,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18222,7 +26068,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18231,20 +26077,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18276,26 +26122,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::ReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -18306,7 +26153,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18327,13 +26174,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -18349,6 +26197,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,15 +26212,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18403,13 +26252,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,15 +26270,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18460,13 +26310,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,20 +26325,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -18498,7 +26349,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18519,13 +26370,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -18544,6 +26396,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,15 +26411,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18598,6 +26451,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18608,15 +26462,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18644,6 +26498,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +26509,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18673,15 +26529,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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", @@ -18697,6 +26553,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18723,6 +26580,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26591,107 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.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::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() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - model.Validate(); + Subscriptions::ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : 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::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::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -18787,7 +26700,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 +26708,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::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::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence 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 +26734,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 ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18884,55 +26797,73 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18944,7 +26875,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18965,7 +26896,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18973,7 +26904,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18984,7 +26915,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19001,7 +26932,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19010,20 +26941,21 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19055,27 +26987,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::ReplacePricePriceCumulativeGroupedAllocationCadence - > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence + > expectedCadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19085,7 +27016,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19106,14 +27037,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -19128,6 +27057,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +27072,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19182,13 +27113,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 +27131,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19239,13 +27172,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,21 +27187,19 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence - > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence + > expectedCadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19277,7 +27209,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19298,14 +27230,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -19323,6 +27253,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +27268,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19377,6 +27309,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19387,15 +27320,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19423,6 +27357,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27368,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19452,15 +27389,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19476,6 +27414,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19502,6 +27441,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27452,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceDailyCreditAllowance { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, ItemID = "item_id", Name = "Annual fee", @@ -19535,29 +27477,84 @@ 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::ReplacePricePriceDailyCreditAllowance + { + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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::ReplacePricePriceDailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceCadenceTest : 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::ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Custom)] public void Validation_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -19566,7 +27563,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 +27571,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::ReplacePricePriceDailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence 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,40 +27597,182 @@ 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 ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = 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::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -19641,17 +27780,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19663,30 +27800,28 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -19694,24 +27829,38 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + Subscriptions::ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19723,7 +27872,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19744,7 +27893,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19752,7 +27901,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19763,7 +27912,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19780,7 +27929,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19789,16 +27938,24 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19828,19 +27985,25 @@ 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 expectedCadence = + Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19850,7 +28013,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19871,12 +28034,13 @@ 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -19890,6 +28054,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +28069,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19938,15 +28111,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 +28129,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19988,26 +28171,33 @@ 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 expectedCadence = + Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20017,7 +28207,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20038,12 +28228,13 @@ 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20060,6 +28251,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +28266,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -20108,6 +28308,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20118,11 +28319,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -20148,6 +28357,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28368,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -20171,11 +28390,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -20189,6 +28416,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20215,6 +28443,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28454,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceMeteredAllowance { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -20242,27 +28480,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::ReplacePricePriceMeteredAllowance + { + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::ReplacePricePriceMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceMeteredAllowanceCadenceTest : 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::ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Custom)] + public void Validation_Works(Subscriptions::ReplacePricePriceMeteredAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -20270,7 +28564,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 +28572,22 @@ 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::ReplacePricePriceMeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceMinimumCadence rawValue + Subscriptions::ReplacePricePriceMeteredAllowanceCadence 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 +28597,63 @@ 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 ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20354,34 +28664,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -20390,21 +28716,29 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); @@ -20413,39 +28747,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + Subscriptions::ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20457,7 +28819,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20478,7 +28840,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20486,7 +28848,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20497,7 +28859,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20514,7 +28876,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20562,6 +28924,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20601,6 +28964,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 +28984,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +29033,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20718,6 +29084,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20764,6 +29131,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 +29154,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +29203,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20874,6 +29244,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29287,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20941,6 +29314,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29343,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 +29515,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 +29654,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21266,6 +29700,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 +29720,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +29774,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21393,6 +29830,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21445,6 +29883,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 +29906,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +29960,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21565,6 +30006,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30059,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21642,6 +30086,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30120,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 +30381,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..61fc53cd7 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs @@ -78,20 +78,39 @@ public void Url_Works() { SubscriptionID = "subscription_id", Currency = "currency", - TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), - TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00.000+00:00"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00.000+00:00"), ViewMode = ViewMode.Periodic, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00%2b00%3a00&view_mode=periodic" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/costs?currency=currency&timeframe_end=2022-03-01T05%3a00%3a00.000%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00.000%2b00%3a00&view_mode=periodic" + ), + 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..76f48a901 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() @@ -88,6 +89,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -135,6 +137,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 +212,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -224,6 +233,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -271,6 +281,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 +367,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -371,6 +388,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -418,6 +436,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 +525,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -521,6 +546,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -568,6 +594,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 +676,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -664,6 +697,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -711,6 +745,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 +831,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -811,6 +852,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -858,6 +900,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 +923,158 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..47c86edb5 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs @@ -22,6 +22,21 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions/subscription_id"), url); + Assert.True( + TestBase.UrisEqual( + 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..b96a59735 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs @@ -125,6 +125,32 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { SubscriptionFetchScheduleParams parameters = new() + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + Limit = 1, + StartDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + StartDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + StartDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + StartDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/schedule?cursor=cursor&limit=1&start_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionFetchScheduleParams { SubscriptionID = "subscription_id", Cursor = "cursor", @@ -135,13 +161,8 @@ public void Url_Works() StartDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + SubscriptionFetchScheduleParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/schedule?cursor=cursor&limit=1&start_date%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&start_date%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00" - ), - url - ); + 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..e143d673a 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs @@ -133,20 +133,45 @@ public void Url_Works() 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"), + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00.000+00:00"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00.000+00:00"), ViewMode = SubscriptionFetchUsageParamsViewMode.Periodic, }; var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/usage?billable_metric_id=billable_metric_id&first_dimension_key=first_dimension_key&first_dimension_value=first_dimension_value&granularity=day&group_by=group_by&second_dimension_key=second_dimension_key&second_dimension_value=second_dimension_value&timeframe_end=2022-03-01T05%3a00%3a00%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00%2b00%3a00&view_mode=periodic" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/usage?billable_metric_id=billable_metric_id&first_dimension_key=first_dimension_key&first_dimension_value=first_dimension_value&granularity=day&group_by=group_by&second_dimension_key=second_dimension_key&second_dimension_value=second_dimension_value&timeframe_end=2022-03-01T05%3a00%3a00.000%2b00%3a00&timeframe_start=2022-02-01T05%3a00%3a00.000%2b00%3a00&view_mode=periodic" + ), + 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..fc7c92d87 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs @@ -179,6 +179,36 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() public void Url_Works() { SubscriptionListParams parameters = new() + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117+00:00"), + Cursor = "cursor", + CustomerID = ["string"], + ExternalCustomerID = ["string"], + ExternalPlanID = "external_plan_id", + Limit = 1, + PlanID = "plan_id", + Status = Status.Active, + }; + + var url = parameters.Url(new() { ApiKey = "My API Key" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&customer_id%5b%5d=string&external_customer_id%5b%5d=string&external_plan_id=external_plan_id&limit=1&plan_id=plan_id&status=active" + ), + 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"), @@ -193,14 +223,9 @@ public void Url_Works() Status = Status.Active, }; - var url = parameters.Url(new() { ApiKey = "My API Key" }); + SubscriptionListParams copied = new(parameters); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions?created_at%5bgt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5bgte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blt%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&created_at%5blte%5d=2019-12-27T18%3a11%3a19.117%2b00%3a00&cursor=cursor&customer_id%5b%5d=string&external_customer_id%5b%5d=string&external_plan_id=external_plan_id&limit=1&plan_id=plan_id&status=active" - ), - url - ); + Assert.Equal(parameters, copied); } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index 73d6484b8..e85586679 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -20,7 +20,7 @@ public void FieldRoundtrip_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -42,11 +42,13 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -58,6 +60,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -95,6 +101,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -105,7 +112,7 @@ public void FieldRoundtrip_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -127,7 +134,7 @@ public void FieldRoundtrip_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }, ], AllowInvoiceCreditOrVoid = true, @@ -139,7 +146,7 @@ public void FieldRoundtrip_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -149,7 +156,11 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }, ], @@ -158,8 +169,8 @@ public void FieldRoundtrip_Works() new() { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }, ], }; @@ -169,7 +180,7 @@ public void FieldRoundtrip_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -191,11 +202,13 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -207,6 +220,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -243,6 +260,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -253,7 +271,7 @@ public void FieldRoundtrip_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -275,7 +293,7 @@ public void FieldRoundtrip_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }, ]; bool expectedAllowInvoiceCreditOrVoid = true; @@ -287,7 +305,7 @@ public void FieldRoundtrip_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -297,7 +315,11 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }, ]; @@ -306,8 +328,8 @@ public void FieldRoundtrip_Works() new() { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }, ]; @@ -396,7 +418,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -418,11 +440,13 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -434,6 +458,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -471,6 +499,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -481,7 +510,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -503,7 +532,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }, ], Edit = @@ -513,7 +542,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -523,7 +552,11 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }, ], @@ -532,8 +565,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() new() { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }, ], }; @@ -554,7 +587,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -576,11 +609,13 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -592,6 +627,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -629,6 +668,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -639,7 +679,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() [ new() { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -661,7 +701,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }, ], Edit = @@ -671,7 +711,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -681,7 +721,11 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }, ], @@ -690,8 +734,8 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() new() { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }, ], @@ -715,11 +759,183 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/price_intervals"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/price_intervals"), + url + ) ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Subscriptions::SubscriptionPriceIntervalsParams + { + SubscriptionID = "subscription_id", + Add = + [ + new() + { + StartDate = BillingCycleRelativeDate.StartOfTerm, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + CanDeferBilling = true, + Discounts = [new Subscriptions::Amount(0)], + EndDate = BillingCycleRelativeDate.StartOfTerm, + 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 = BillingCycleRelativeDate.StartOfTerm, + 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 = BillingCycleRelativeDate.StartOfTerm, + }, + ], + AllowInvoiceCreditOrVoid = true, + CanDeferBilling = true, + Edit = + [ + new() + { + PriceIntervalID = "sdfs6wdjvn7ujokd", + BillingCycleDay = 0, + CanDeferBilling = true, + EndDate = BillingCycleRelativeDate.StartOfTerm, + 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 = BillingCycleRelativeDate.StartOfTerm, + UsageCustomerIds = ["string"], + }, + ], + EditAdjustments = + [ + new() + { + AdjustmentIntervalID = "sdfs6wdjvn7ujokd", + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, + }, + ], + }; + + Subscriptions::SubscriptionPriceIntervalsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddTest : TestBase @@ -729,7 +945,7 @@ public void FieldRoundtrip_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -751,11 +967,13 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -767,6 +985,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -803,15 +1025,14 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", UsageCustomerIds = ["string"], }; - Subscriptions::StartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::StartDate expectedStartDate = BillingCycleRelativeDate.StartOfTerm; NewAllocationPrice expectedAllocationPrice = new() { Amount = "10.00", @@ -833,11 +1054,13 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; List expectedDiscounts = [new Subscriptions::Amount(0)]; - Subscriptions::EndDate expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Subscriptions::EndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; string expectedExternalPriceID = "external_price_id"; string expectedFilter = "my_property > 100 AND my_other_property = 'bar'"; List expectedFixedFeeQuantityTransitions = @@ -849,6 +1072,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 +1112,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -915,6 +1143,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); @@ -931,7 +1167,7 @@ public void SerializationRoundtrip_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -953,11 +1189,13 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -969,6 +1207,10 @@ public void SerializationRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1005,6 +1247,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1025,7 +1268,7 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -1047,11 +1290,13 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -1063,6 +1308,10 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1099,6 +1348,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1112,9 +1362,7 @@ public void FieldRoundtripThroughSerialization_Works() ); Assert.NotNull(deserialized); - Subscriptions::StartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::StartDate expectedStartDate = BillingCycleRelativeDate.StartOfTerm; NewAllocationPrice expectedAllocationPrice = new() { Amount = "10.00", @@ -1136,11 +1384,13 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; List expectedDiscounts = [new Subscriptions::Amount(0)]; - Subscriptions::EndDate expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + Subscriptions::EndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; string expectedExternalPriceID = "external_price_id"; string expectedFilter = "my_property > 100 AND my_other_property = 'bar'"; List expectedFixedFeeQuantityTransitions = @@ -1152,6 +1402,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 +1442,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -1218,6 +1473,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); @@ -1234,7 +1502,7 @@ public void Validation_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = new() { Amount = "10.00", @@ -1256,11 +1524,13 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, Discounts = [new Subscriptions::Amount(0)], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, ExternalPriceID = "external_price_id", Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = @@ -1272,6 +1542,10 @@ public void Validation_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1308,6 +1582,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1320,10 +1595,7 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Add - { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; + var model = new Subscriptions::Add { StartDate = BillingCycleRelativeDate.StartOfTerm }; Assert.Null(model.AllocationPrice); Assert.False(model.RawData.ContainsKey("allocation_price")); @@ -1341,6 +1613,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); @@ -1354,10 +1628,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Add - { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; + var model = new Subscriptions::Add { StartDate = BillingCycleRelativeDate.StartOfTerm }; model.Validate(); } @@ -1367,7 +1638,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = null, CanDeferBilling = null, @@ -1377,6 +1648,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1399,6 +1671,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); @@ -1414,7 +1688,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new Subscriptions::Add { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, AllocationPrice = null, CanDeferBilling = null, @@ -1424,6 +1698,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1432,54 +1707,151 @@ 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() + public void CopyConstructor_Works() { - 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] + var model = new Subscriptions::Add + { + StartDate = BillingCycleRelativeDate.StartOfTerm, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + CanDeferBilling = true, + Discounts = [new Subscriptions::Amount(0)], + EndDate = BillingCycleRelativeDate.StartOfTerm, + 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); @@ -1594,6 +1966,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 +2032,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 +2098,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 +2223,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 +2279,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1918,6 +2335,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1961,6 +2379,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2011,6 +2430,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2054,6 +2474,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2102,6 +2523,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2153,6 +2575,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2204,6 +2627,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2266,6 +2690,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2317,6 +2742,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2378,6 +2804,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2426,6 +2853,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2469,6 +2897,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2518,11 +2947,83 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Subscriptions::PriceModel value = + new Subscriptions::PriceModelMatrixWithThresholdDiscounts() + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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(); + } + [Fact] public void NewFloatingTieredWithProrationValidationWorks() { @@ -2563,6 +3064,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2606,6 +3108,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2654,6 +3157,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2702,6 +3206,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2751,6 +3256,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2809,6 +3315,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2857,6 +3364,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2912,6 +3420,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2964,6 +3473,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3016,6 +3526,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3045,6 +3556,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3075,6 +3587,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3137,6 +3650,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3192,6 +3706,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3240,20 +3755,28 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelMinimum() + Subscriptions::PriceModel value = new Subscriptions::PriceModelDailyCreditAllowance() { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3282,21 +3805,29 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingMinimumCompositeValidationWorks() + public void MeteredAllowanceValidationWorks() { - Subscriptions::PriceModel value = new NewFloatingMinimumCompositePrice() + Subscriptions::PriceModel value = new Subscriptions::PriceModelMeteredAllowance() { - Cadence = NewFloatingMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = NewFloatingMinimumCompositePriceModelType.MinimumComposite, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3325,21 +3856,23 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void PercentValidationWorks() + public void NewFloatingMinimumCompositeValidationWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelPercent() + Subscriptions::PriceModel value = new NewFloatingMinimumCompositePrice() { - Cadence = Subscriptions::PriceModelPercentCadence.Annual, + Cadence = NewFloatingMinimumCompositePriceCadence.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() @@ -3367,26 +3900,22 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void EventOutputValidationWorks() + public void PercentValidationWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelEventOutput() + Subscriptions::PriceModel value = new Subscriptions::PriceModelPercent() { - Cadence = Subscriptions::PriceModelEventOutputCadence.Annual, + Cadence = Subscriptions::PriceModelPercentCadence.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() @@ -3414,15 +3943,64 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); } [Fact] - public void NewFloatingUnitSerializationRoundtripWorks() + public void EventOutputValidationWorks() { - Subscriptions::PriceModel value = new NewFloatingUnitPrice() + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void NewFloatingUnitSerializationRoundtripWorks() + { + Subscriptions::PriceModel value = new NewFloatingUnitPrice() { Cadence = NewFloatingUnitPriceCadence.Annual, Currency = "currency", @@ -3457,6 +4035,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 +4097,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 +4147,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 +4204,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 +4254,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 +4309,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 +4367,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 +4425,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 +4494,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 +4552,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 +4620,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 +4675,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 +4725,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 +4781,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); @@ -4201,6 +4793,83 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } + [Fact] + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() + { + Subscriptions::PriceModel value = + new Subscriptions::PriceModelMatrixWithThresholdDiscounts() + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + [Fact] public void NewFloatingTieredWithProrationSerializationRoundtripWorks() { @@ -4241,6 +4910,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 +4960,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 +5015,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 +5070,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 +5126,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 +5191,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 +5246,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 +5308,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 +5367,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 +5426,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 +5462,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4813,6 +5493,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 +5562,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 +5624,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 +5679,63 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + 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 DailyCreditAllowanceSerializationRoundtripWorks() + { + Subscriptions::PriceModel value = new Subscriptions::PriceModelDailyCreditAllowance() + { + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5008,14 +5748,22 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelMinimum() + Subscriptions::PriceModel value = new Subscriptions::PriceModelMeteredAllowance() { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5044,6 +5792,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); @@ -5093,6 +5842,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); @@ -5141,6 +5891,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); @@ -5194,6 +5945,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); @@ -5253,6 +6005,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5300,6 +6053,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 +6072,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +6128,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5430,6 +6186,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5484,6 +6241,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 +6263,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +6319,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5606,6 +6366,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +6424,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5685,6 +6448,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +6483,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 +6663,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 +6755,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 +6893,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 @@ -6190,23 +7056,42 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceModelGroupedWithMinMaxThresholdsTest : TestBase +public class PriceModelMatrixWithThresholdDiscountsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6235,25 +7120,2663 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; ApiEnum< string, - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence - > expectedCadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence + > expectedCadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual; string expectedCurrency = "currency"; - Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + string expectedItemID = "item_id"; + Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PriceModelMatrixWithThresholdDiscountsConversionRateConfig 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, + }; + 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( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, 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.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + + string json = 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::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence + > expectedCadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PriceModelMatrixWithThresholdDiscountsConversionRateConfig 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, + }; + 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( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, 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.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelMatrixWithThresholdDiscounts + { + Cadence = Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "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::PriceModelMatrixWithThresholdDiscounts copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelMatrixWithThresholdDiscountsCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Custom)] + public void Validation_Works( + Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force 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::PriceModelMatrixWithThresholdDiscountsCadence.Annual)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = 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::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + 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 expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string json = 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::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + Subscriptions::PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelMatrixWithThresholdDiscountsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::PriceModelMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::PriceModelMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::PriceModelMatrixWithThresholdDiscountsConversionRateConfig 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::PriceModelMatrixWithThresholdDiscountsConversionRateConfig 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 PriceModelGroupedWithMinMaxThresholdsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum< + string, + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence + > expectedCadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedCurrency, model.Currency); + 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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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::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" } }, + }; + + string json = 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::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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence + > expectedCadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig 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, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedCurrency, deserialized.Currency); + 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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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::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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = 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.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + 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 +{ + [Theory] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works( + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + 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::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + 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 +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig 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::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig 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 PriceModelCumulativeGroupedAllocationTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum< + string, + Subscriptions::PriceModelCumulativeGroupedAllocationCadence + > expectedCadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual; + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCurrency = "currency"; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6264,7 +9787,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6284,14 +9807,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedCurrency, model.Currency); Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); + Assert.Equal(expectedCurrency, model.Currency); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -6305,6 +9829,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6318,17 +9843,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6358,12 +9883,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6374,17 +9900,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6414,12 +9940,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6427,20 +9954,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence - > expectedCadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual; - string expectedCurrency = "currency"; - Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::PriceModelCumulativeGroupedAllocationCadence + > expectedCadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual; + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCurrency = "currency"; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -6451,7 +9978,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6471,14 +9998,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedCurrency, deserialized.Currency); Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); + Assert.Equal(expectedCurrency, deserialized.Currency); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -6495,6 +10023,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6508,17 +10037,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6548,6 +10077,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6557,17 +10087,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -6592,6 +10122,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6599,17 +10131,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -6620,17 +10152,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -6644,6 +10176,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6667,6 +10200,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6674,17 +10209,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation { - Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - Currency = "currency", - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, + Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -6698,28 +10233,81 @@ 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 PriceModelGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class PriceModelCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Custom)] public void Validation_Works( - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::PriceModelCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -6728,7 +10316,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -6736,23 +10324,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::PriceModelCumulativeGroupedAllocationCadence 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); @@ -6762,57 +10350,57 @@ 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 PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase +public class PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + 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(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::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6824,55 +10412,73 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6884,7 +10490,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6905,7 +10511,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6913,7 +10519,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6924,7 +10530,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6941,7 +10547,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6950,22 +10556,23 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceModelCumulativeGroupedAllocationTest : TestBase +public class PriceModelDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6995,26 +10602,24 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum< - string, - Subscriptions::PriceModelCumulativeGroupedAllocationCadence - > expectedCadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual; - Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7024,7 +10629,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7044,14 +10649,12 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -7065,6 +10668,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7078,17 +10682,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -7118,12 +10723,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7134,17 +10740,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -7174,34 +10781,32 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::PriceModelCumulativeGroupedAllocationCadence - > expectedCadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual; - Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCurrency = "currency"; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7211,7 +10816,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7231,14 +10836,12 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -7255,6 +10858,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7268,17 +10872,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -7308,6 +10913,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7317,17 +10923,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -7352,6 +10959,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7359,17 +10968,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", }; @@ -7380,17 +10990,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -7404,6 +11015,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7427,6 +11039,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7434,17 +11048,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + var model = new Subscriptions::PriceModelDailyCreditAllowance { - Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -7458,29 +11073,80 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; - model.Validate(); + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelDailyCreditAllowance + { + Cadence = Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual, + Currency = "currency", + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], 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"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + 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::PriceModelDailyCreditAllowance copied = new(model); + + Assert.Equal(model, copied); } } -public class PriceModelCumulativeGroupedAllocationCadenceTest : TestBase +public class PriceModelDailyCreditAllowanceCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works( - Subscriptions::PriceModelCumulativeGroupedAllocationCadence rawValue - ) + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Custom)] + public void Validation_Works(Subscriptions::PriceModelDailyCreditAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -7488,7 +11154,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -7496,23 +11162,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Custom)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Monthly)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.OneTime)] + [InlineData(Subscriptions::PriceModelDailyCreditAllowanceCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::PriceModelCumulativeGroupedAllocationCadence rawValue + Subscriptions::PriceModelDailyCreditAllowanceCadence 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); @@ -7522,39 +11187,174 @@ 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 PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase +public class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = 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::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -7562,17 +11362,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7584,30 +11382,28 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -7615,24 +11411,38 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } } -public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class PriceModelDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7644,7 +11454,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7665,7 +11475,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7673,7 +11483,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7684,7 +11494,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7701,7 +11511,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7710,17 +11520,25 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceModelMinimumTest : TestBase +public class PriceModelMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7749,19 +11567,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = - Subscriptions::PriceModelMinimumCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::PriceModelMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - Subscriptions::PriceModelMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7771,7 +11595,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7791,12 +11615,13 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -7809,6 +11634,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7822,12 +11648,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7856,11 +11690,12 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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 ); @@ -7871,12 +11706,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7905,26 +11748,32 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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 = - Subscriptions::PriceModelMinimumCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::PriceModelMeteredAllowanceCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - Subscriptions::PriceModelMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7934,7 +11783,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7954,12 +11803,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -7975,6 +11825,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7988,12 +11839,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8022,6 +11881,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8031,12 +11891,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -8060,6 +11928,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -8067,12 +11937,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", }; @@ -8082,12 +11960,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -8100,6 +11986,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8123,6 +12010,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -8130,12 +12019,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::PriceModelMinimum + var model = new Subscriptions::PriceModelMeteredAllowance { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", BillableMetricID = null, @@ -8148,26 +12045,81 @@ 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::PriceModelMeteredAllowance + { + Cadence = Subscriptions::PriceModelMeteredAllowanceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "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::PriceModelMeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceModelMinimumCadenceTest : TestBase +public class PriceModelMeteredAllowanceCadenceTest : 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) + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Custom)] + public void Validation_Works(Subscriptions::PriceModelMeteredAllowanceCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -8175,7 +12127,7 @@ public void Validation_Works(Subscriptions::PriceModelMinimumCadence rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -8183,20 +12135,22 @@ public void InvalidEnumValidationThrows_Works() } [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) + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Annual)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.SemiAnnual)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Monthly)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Quarterly)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.OneTime)] + [InlineData(Subscriptions::PriceModelMeteredAllowanceCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::PriceModelMeteredAllowanceCadence 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); @@ -8206,47 +12160,63 @@ public void SerializationRoundtrip_Works(Subscriptions::PriceModelMinimumCadence 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 PriceModelMinimumMinimumConfigTest : TestBase +public class PriceModelMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8257,34 +12227,50 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -8293,21 +12279,29 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); @@ -8316,39 +12310,67 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + Subscriptions::PriceModelMeteredAllowanceMeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class PriceModelMinimumConversionRateConfigTest : TestBase +public class PriceModelMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8360,7 +12382,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8381,7 +12403,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8389,7 +12411,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8400,7 +12422,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8417,7 +12439,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8465,6 +12487,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8503,6 +12526,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 +12545,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12593,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8617,6 +12643,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8662,6 +12689,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 +12711,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12759,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8768,6 +12798,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +12840,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8831,6 +12864,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +12891,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 +13059,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 +13198,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9149,6 +13242,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 +13261,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +13314,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9273,6 +13369,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9323,6 +13420,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 +13442,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +13495,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9439,6 +13539,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +13591,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9512,6 +13615,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +13647,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 +13904,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 @@ -9839,7 +14011,7 @@ public void FieldRoundtrip_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -9861,11 +14033,11 @@ public void FieldRoundtrip_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentStartDate expectedStartDate = - DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + BillingCycleRelativeDate.StartOfTerm; Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() { @@ -9889,7 +14061,7 @@ public void FieldRoundtrip_Works() }; string expectedAdjustmentID = "h74gfhdjvn7ujokd"; Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentEndDate expectedEndDate = - DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + BillingCycleRelativeDate.StartOfTerm; Assert.Equal(expectedStartDate, model.StartDate); Assert.Equal(expectedAdjustment, model.Adjustment); @@ -9902,7 +14074,7 @@ public void SerializationRoundtrip_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -9924,7 +14096,7 @@ public void SerializationRoundtrip_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -9942,7 +14114,7 @@ public void FieldRoundtripThroughSerialization_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -9964,7 +14136,7 @@ public void FieldRoundtripThroughSerialization_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -9976,7 +14148,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentStartDate expectedStartDate = - DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + BillingCycleRelativeDate.StartOfTerm; Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() { @@ -10000,7 +14172,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedAdjustmentID = "h74gfhdjvn7ujokd"; Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustmentEndDate expectedEndDate = - DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + BillingCycleRelativeDate.StartOfTerm; Assert.Equal(expectedStartDate, deserialized.StartDate); Assert.Equal(expectedAdjustment, deserialized.Adjustment); @@ -10013,7 +14185,7 @@ public void Validation_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = new NewPercentageDiscount() { AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, @@ -10035,7 +14207,7 @@ public void Validation_Works() PriceType = NewPercentageDiscountPriceType.Usage, }, AdjustmentID = "h74gfhdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -10046,7 +14218,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; Assert.Null(model.Adjustment); @@ -10062,7 +14234,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -10073,7 +14245,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = null, AdjustmentID = null, @@ -10093,7 +14265,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment { - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, Adjustment = null, AdjustmentID = null, @@ -10102,6 +14274,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment + { + StartDate = BillingCycleRelativeDate.StartOfTerm, + 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 = BillingCycleRelativeDate.StartOfTerm, + }; + + Subscriptions::SubscriptionPriceIntervalsParamsAddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionPriceIntervalsParamsAddAdjustmentStartDateTest : TestBase @@ -10522,7 +14729,7 @@ public void FieldRoundtrip_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10532,16 +14739,18 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }; string expectedPriceIntervalID = "sdfs6wdjvn7ujokd"; long expectedBillingCycleDay = 0; bool expectedCanDeferBilling = true; - Subscriptions::EditEndDate expectedEndDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::EditEndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; string expectedFilter = "my_property > 100 AND my_other_property = 'bar'"; List expectedFixedFeeQuantityTransitions = [ @@ -10551,9 +14760,11 @@ public void FieldRoundtrip_Works() Quantity = 5, }, ]; - Subscriptions::EditStartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + Subscriptions::EditStartDate expectedStartDate = BillingCycleRelativeDate.StartOfTerm; List expectedUsageCustomerIds = ["string"]; Assert.Equal(expectedPriceIntervalID, model.PriceIntervalID); @@ -10573,6 +14784,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); @@ -10590,7 +14809,7 @@ public void SerializationRoundtrip_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10600,7 +14819,11 @@ public void SerializationRoundtrip_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }; @@ -10621,7 +14844,7 @@ public void FieldRoundtripThroughSerialization_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10631,7 +14854,11 @@ public void FieldRoundtripThroughSerialization_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }; @@ -10645,9 +14872,7 @@ public void FieldRoundtripThroughSerialization_Works() string expectedPriceIntervalID = "sdfs6wdjvn7ujokd"; long expectedBillingCycleDay = 0; bool expectedCanDeferBilling = true; - Subscriptions::EditEndDate expectedEndDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::EditEndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; string expectedFilter = "my_property > 100 AND my_other_property = 'bar'"; List expectedFixedFeeQuantityTransitions = [ @@ -10657,9 +14882,11 @@ public void FieldRoundtripThroughSerialization_Works() Quantity = 5, }, ]; - Subscriptions::EditStartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + Subscriptions::EditStartDate expectedStartDate = BillingCycleRelativeDate.StartOfTerm; List expectedUsageCustomerIds = ["string"]; Assert.Equal(expectedPriceIntervalID, deserialized.PriceIntervalID); @@ -10679,6 +14906,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); @@ -10696,7 +14936,7 @@ public void Validation_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10706,7 +14946,11 @@ public void Validation_Works() Quantity = 5, }, ], - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = BillingCycleRelativeDate.StartOfTerm, UsageCustomerIds = ["string"], }; @@ -10721,7 +14965,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10731,6 +14975,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10746,7 +14994,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10756,6 +15004,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10770,7 +15022,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10780,6 +15032,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 @@ -10798,7 +15054,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() PriceIntervalID = "sdfs6wdjvn7ujokd", BillingCycleDay = 0, CanDeferBilling = true, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, Filter = "my_property > 100 AND my_other_property = 'bar'", FixedFeeQuantityTransitions = [ @@ -10808,6 +15064,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 @@ -10823,7 +15083,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new Subscriptions::Edit { PriceIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; Assert.Null(model.BillingCycleDay); @@ -10836,6 +15096,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")); } @@ -10846,7 +15108,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new Subscriptions::Edit { PriceIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -10858,13 +15120,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new Subscriptions::Edit { PriceIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, BillingCycleDay = null, CanDeferBilling = null, EndDate = null, Filter = null, FixedFeeQuantityTransitions = null, + MetricParameterOverrides = null, UsageCustomerIds = null, }; @@ -10878,6 +15141,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")); } @@ -10888,18 +15153,50 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Subscriptions::Edit { PriceIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, BillingCycleDay = null, CanDeferBilling = null, 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 = BillingCycleRelativeDate.StartOfTerm, + 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 = BillingCycleRelativeDate.StartOfTerm, + UsageCustomerIds = ["string"], + }; + + Subscriptions::Edit copied = new(model); + + Assert.Equal(model, copied); + } } public class EditEndDateTest : TestBase @@ -11017,6 +15314,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 @@ -11070,17 +15381,14 @@ public void FieldRoundtrip_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"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }; string expectedAdjustmentIntervalID = "sdfs6wdjvn7ujokd"; - Subscriptions::EditAdjustmentEndDate expectedEndDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); - Subscriptions::EditAdjustmentStartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::EditAdjustmentEndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; + Subscriptions::EditAdjustmentStartDate expectedStartDate = + BillingCycleRelativeDate.StartOfTerm; Assert.Equal(expectedAdjustmentIntervalID, model.AdjustmentIntervalID); Assert.Equal(expectedEndDate, model.EndDate); @@ -11093,8 +15401,8 @@ public void SerializationRoundtrip_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"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -11112,8 +15420,8 @@ public void FieldRoundtripThroughSerialization_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"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -11124,12 +15432,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); string expectedAdjustmentIntervalID = "sdfs6wdjvn7ujokd"; - Subscriptions::EditAdjustmentEndDate expectedEndDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); - Subscriptions::EditAdjustmentStartDate expectedStartDate = DateTimeOffset.Parse( - "2019-12-27T18:11:19.117Z" - ); + Subscriptions::EditAdjustmentEndDate expectedEndDate = BillingCycleRelativeDate.StartOfTerm; + Subscriptions::EditAdjustmentStartDate expectedStartDate = + BillingCycleRelativeDate.StartOfTerm; Assert.Equal(expectedAdjustmentIntervalID, deserialized.AdjustmentIntervalID); Assert.Equal(expectedEndDate, deserialized.EndDate); @@ -11142,8 +15447,8 @@ public void Validation_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"), + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -11155,7 +15460,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; Assert.Null(model.StartDate); @@ -11168,7 +15473,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -11180,7 +15485,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, // Null should be interpreted as omitted for these properties StartDate = null, @@ -11196,7 +15501,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + EndDate = BillingCycleRelativeDate.StartOfTerm, // Null should be interpreted as omitted for these properties StartDate = null, @@ -11211,7 +15516,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; Assert.Null(model.EndDate); @@ -11224,7 +15529,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, }; model.Validate(); @@ -11236,7 +15541,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, EndDate = null, }; @@ -11251,13 +15556,28 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Subscriptions::EditAdjustment { AdjustmentIntervalID = "sdfs6wdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = BillingCycleRelativeDate.StartOfTerm, EndDate = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::EditAdjustment + { + AdjustmentIntervalID = "sdfs6wdjvn7ujokd", + EndDate = BillingCycleRelativeDate.StartOfTerm, + StartDate = BillingCycleRelativeDate.StartOfTerm, + }; + + 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..bcdc35106 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs @@ -90,11 +90,31 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/redeem_coupon"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/redeem_coupon"), + 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..5bde280c9 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -72,6 +72,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -87,6 +89,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 +131,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -212,6 +219,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -227,6 +236,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 +277,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -334,6 +348,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -349,6 +365,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 +406,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -477,6 +498,8 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -492,6 +515,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 +555,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -776,590 +804,4080 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/schedule_plan_change" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/schedule_plan_change" + ), + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AlignBillingWithPlanChangeDate = true, + AutoCollection = true, + BillingCycleAlignment = Subscriptions::BillingCycleAlignment.Unchanged, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ChangeDate = DateTimeOffset.Parse("2017-07-21T17:32:28Z"), + CouponRedemptionCode = "coupon_redemption_code", + CreditsOverageRate = 0, + DefaultInvoiceMemo = "default_invoice_memo", + ExternalPlanID = "ZMwNQefe7J3ecf7W", + Filter = "my_property > 100 AND my_other_property = 'bar'", + InitialPhaseOrder = 2, + InvoicingThreshold = "10.00", + NetTerms = 0, + PerCreditOverageAmount = 0, + PlanID = "ZMwNQefe7J3ecf7W", + PlanVersionNumber = 0, + PriceOverrides = [JsonSerializer.Deserialize("{}")], + RemoveAdjustments = [new("h74gfhdjvn7ujokd")], + RemovePrices = + [ + new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" }, + ], + ReplaceAdjustments = + [ + new() + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }, + ], + ReplacePrices = + [ + new() + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }, + ], + TrialDurationDays = 0, + UsageCustomerIds = ["string"], }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + 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 InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm + )] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedStartDate, model.StartDate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase +{ + [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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"), + }; + + 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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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"; + 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 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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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"; + 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 Validation_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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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"), + }; + + 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 OptionalNullablePropertiesSetToNullValidation_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, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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::SubscriptionSchedulePlanChangeParamsAddPrice copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionBulkValidationWorks() + { + 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"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void BulkWithFiltersValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionPackageValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionThresholdTotalAmountValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + { + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredPackageValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionTieredWithMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedTieredValidationWorks() + { + 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"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionPackageWithAllocationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitWithPercentValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void NewSubscriptionMatrixWithAllocationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void MatrixWithThresholdDiscountsValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); + } + + [Fact] + public void TieredWithProrationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitWithProrationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedAllocationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionBulkWithProrationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void GroupedWithMinMaxThresholdsValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedTieredPackageValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + [Fact] + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }; - 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); + value.Validate(); } [Fact] - public void Validation_Works() + public void CumulativeGroupedAllocationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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(); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void DailyCreditAllowanceValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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", - 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", + }; + value.Validate(); + } - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); + [Fact] + public void MeteredAllowanceValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionMinimumCompositeValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - model.Validate(); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void PercentValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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")); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void EventOutputValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - model.Validate(); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } -} -public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + 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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewUsageDiscountValidationWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewAmountDiscountValidationWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkPrice() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewMinimumValidationWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + BulkWithFiltersConfig = new() + { + 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", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_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 = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewMaximumValidationWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackagePrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - 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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1368,32 +4886,60 @@ public void NewPercentageDiscountSerializationRoundtripWorks() } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1402,32 +4948,59 @@ public void NewUsageDiscountSerializationRoundtripWorks() } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1436,33 +5009,71 @@ public void NewAmountDiscountSerializationRoundtripWorks() } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -1471,92 +5082,155 @@ public void NewMinimumSerializationRoundtripWorks() } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + 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 = 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", - }, - Discounts = - [ - 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"), }, - ], - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1585,59 +5259,32 @@ public void FieldRoundtrip_Works() 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"), - }; + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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() + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1666,79 +5313,41 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + MatrixWithAllocationConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ], - 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, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1767,73 +5376,113 @@ public void SerializationRoundtrip_Works() 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"), - }; - - 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 MatrixWithThresholdDiscountsSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + 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", - }, - Discounts = - [ - 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"), }, - ], - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 TieredWithProrationSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1862,67 +5511,32 @@ public void FieldRoundtripThroughSerialization_Works() 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"), - }; - - 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); - 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() + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1951,79 +5565,37 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - 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() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, - ], - 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, + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2051,125 +5623,98 @@ public void Validation_Works() { Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; - - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; - - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_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 SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2198,35 +5743,51 @@ public void NewSubscriptionUnitValidationWorks() 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 NewSubscriptionTieredValidationWorks() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - Tiers = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", }, ], - Prorated = true, + 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() @@ -2255,22 +5816,36 @@ public void NewSubscriptionTieredValidationWorks() 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 NewSubscriptionBulkValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2300,30 +5875,43 @@ public void NewSubscriptionBulkValidationWorks() 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 BulkWithFiltersValidationWorks() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Dimension = "dimension", + UnitAmounts = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2353,23 +5941,41 @@ public void BulkWithFiltersValidationWorks() 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 NewSubscriptionPackageValidationWorks() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.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::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2398,30 +6004,40 @@ public void NewSubscriptionPackageValidationWorks() 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 NewSubscriptionMatrixValidationWorks() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MaxGroupTieredPackageConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2451,31 +6067,48 @@ public void NewSubscriptionMatrixValidationWorks() 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 NewSubscriptionThresholdTotalAmountValidationWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - ThresholdTotalAmountConfig = new() + ScalableMatrixWithUnitPricingConfig = new() { - ConsumptionTable = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + 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, @@ -2505,30 +6138,50 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() 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 NewSubscriptionTieredPackageValidationWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - TieredPackageConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - PackageSize = "package_size", + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + 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, @@ -2558,43 +6211,44 @@ public void NewSubscriptionTieredPackageValidationWorks() 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 NewSubscriptionTieredWithMinimumValidationWorks() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Tiers = + DimensionValues = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", + GroupingKey = "x", TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }, ], - HideZeroAmountTiers = true, - Prorate = true, + Group = "group", }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2623,30 +6277,36 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() 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 NewSubscriptionGroupedTieredValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + UnitAmount = "unit_amount", }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2676,42 +6336,41 @@ public void NewSubscriptionGroupedTieredValidationWorks() 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 NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - PackageSize = 0, - Tiers = + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2740,29 +6399,39 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() 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 NewSubscriptionPackageWithAllocationValidationWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + MeteredAllowanceConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2791,24 +6460,36 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() 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 NewSubscriptionUnitWithPercentValidationWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2837,33 +6518,31 @@ public void NewSubscriptionUnitWithPercentValidationWorks() 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 NewSubscriptionMatrixWithAllocationValidationWorks() + public void PercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2892,25 +6571,36 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() 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 TieredWithProrationValidationWorks() + public void EventOutputSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2939,24 +6629,42 @@ public void TieredWithProrationValidationWorks() 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); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2985,28 +6693,108 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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, + }; + 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 NewSubscriptionGroupedAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + 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", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3036,28 +6824,39 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = 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 NewSubscriptionBulkWithProrationValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - BulkWithProrationConfig = new( + BulkWithFiltersConfig = new() + { + 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::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ], + }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3087,29 +6886,119 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = 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); + + 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, + }; + 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 NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + 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", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3139,92 +7028,211 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, 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() + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("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" }, + ], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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() + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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", @@ -3255,571 +7263,639 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); + } +} + +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" }, + ], + }; + + string json = 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - value.Validate(); + + 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 NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", }; - value.Validate(); + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + 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 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 CumulativeGroupedAllocationValidationWorks() + 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); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void PercentValidationWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsTest + : TestBase +{ [Fact] - public void EventOutputValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3849,23 +7925,150 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig 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"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3894,42 +8097,59 @@ 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); + + 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 NewSubscriptionTieredSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - FirstUnit = 0, + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", - LastUnit = 0, + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - Prorated = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3958,29 +8178,160 @@ 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); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig 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"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4010,149 +8361,307 @@ 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); + model.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], }, + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts + { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 NewSubscriptionPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MatrixWithThresholdDiscountsConfig = new() { DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], + FirstDimension = "first_dimension", MatrixValues = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4182,863 +8691,1047 @@ 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); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadenceTest + : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = 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::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + model.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - 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", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + 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 NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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 expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + 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 NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - 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 expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5047,87 +9740,49 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() { - 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", + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase +{ [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.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() @@ -5156,40 +9811,95 @@ 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); + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig 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"; + + 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 NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5218,40 +9928,34 @@ 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); + + 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 NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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() @@ -5280,47 +9984,106 @@ 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); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig 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"; + + 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 NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5349,50 +10112,183 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo 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); + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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" }] + ), + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + { + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.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", - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5421,296 +10317,370 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip 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); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest + : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_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); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + 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 expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - 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 expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5719,55 +10689,26 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 ); @@ -5776,25 +10717,24 @@ public void EventOutputSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5825,27 +10765,28 @@ 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; + 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("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5855,7 +10796,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5876,11 +10817,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( + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5895,6 +10840,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5910,19 +10856,17 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5953,13 +10897,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 ); @@ -5971,19 +10916,17 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6014,35 +10957,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( + 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 + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; + 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("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6052,7 +10996,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6073,11 +11017,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( + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -6095,6 +11043,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6110,19 +11059,17 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -6153,6 +11100,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6164,19 +11112,17 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -6203,6 +11149,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6213,19 +11161,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -6237,19 +11183,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -6264,6 +11208,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6290,6 +11235,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -6297,100 +11244,249 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest + : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + > 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 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 = 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 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 + > + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - 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 expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - 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(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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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 ); @@ -6402,97 +11498,339 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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 expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - 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(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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig 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::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - PropertyKey = "x", - PropertyValue = "x", + 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + 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( + "cumulative_grouped_allocation" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig 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"; - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - PropertyKey = "x", - PropertyValue = "x", + 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 ); @@ -6504,203 +11842,457 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - PropertyKey = "x", - PropertyValue = "x", + 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 ); Assert.NotNull(deserialized); - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + 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( + "cumulative_grouped_allocation" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig 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"; + + 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(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - PropertyKey = "x", - PropertyValue = "x", + 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(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", }; - 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - 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); - } + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - 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(); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - UnitAmount = "unit_amount", - }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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", }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -6711,7 +12303,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -6721,72 +12313,185 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6798,7 +12503,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6819,7 +12524,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6827,7 +12532,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6838,7 +12543,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6855,7 +12560,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6864,21 +12569,29 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, 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 +12620,28 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); 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 +12650,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6950,14 +12671,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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); 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 +12691,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12707,23 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, 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 +12752,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 +12771,23 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, 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,13 +12816,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 ); @@ -7090,14 +12831,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); 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 +12854,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7127,14 +12875,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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); 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 +12898,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12914,23 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, 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 +12959,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7212,15 +12971,23 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -7245,6 +13012,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +13024,23 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -7273,15 +13050,23 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7294,6 +13079,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7320,6 +13106,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,15 +13118,23 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7351,44 +13147,105 @@ 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::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > value = rawValue; value.Validate(); } @@ -7399,7 +13256,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -7409,38 +13266,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -7453,14 +13310,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -7468,27 +13325,43 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - List expectedTiers = + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ]; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) { - Assert.Equal(expectedTiers[i], model.Tiers[i]); + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); } } @@ -7496,14 +13369,18 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7515,28 +13392,44 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ]; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); } } @@ -7544,32 +13437,59 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - TierLowerBound = "tier_lower_bound", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -7577,15 +13497,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - TierLowerBound = "tier_lower_bound", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7597,24 +13517,28 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - TierLowerBound = "tier_lower_bound", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -7622,23 +13546,39 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - TierLowerBound = "tier_lower_bound", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7650,7 +13590,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7671,7 +13611,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7679,7 +13619,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7690,7 +13630,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7707,7 +13647,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7716,25 +13656,26 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7764,27 +13705,28 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7794,7 +13736,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7815,15 +13757,13 @@ 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(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -7837,6 +13777,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7852,18 +13793,20 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7893,13 +13836,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 ); @@ -7911,18 +13855,20 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7952,13 +13898,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 ); @@ -7966,21 +13913,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7990,7 +13937,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8011,15 +13958,13 @@ 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(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -8036,6 +13981,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8051,18 +13997,20 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8092,6 +14040,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8103,18 +14052,20 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", }; @@ -8140,6 +14091,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8150,18 +14103,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", }; @@ -8172,18 +14127,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -8197,6 +14154,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8223,6 +14181,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8233,18 +14193,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -8258,44 +14220,102 @@ 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::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > value = rawValue; value.Validate(); } @@ -8306,7 +14326,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -8316,38 +14336,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -8360,14 +14380,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -8375,47 +14395,55 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8427,56 +14455,158 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, + }; + + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + + // Null should be interpreted as omitted for these properties + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8488,7 +14618,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8509,7 +14639,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8517,7 +14647,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8528,7 +14658,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8545,7 +14675,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8554,76 +14684,61 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + 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() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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() @@ -8632,7 +14747,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8653,17 +14768,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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8675,6 +14788,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8689,55 +14803,49 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + 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() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 ); @@ -8748,55 +14856,49 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + 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() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 ); @@ -8804,22 +14906,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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() @@ -8828,7 +14922,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8849,17 +14943,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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8874,6 +14966,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8888,51 +14981,45 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + 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() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } @@ -8940,21 +15027,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_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", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -8978,6 +15058,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8987,21 +15069,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_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", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + }; model.Validate(); } @@ -9009,35 +15084,29 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_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", + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -9061,6 +15130,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9070,70 +15141,111 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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", + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + 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::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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; value.Validate(); } @@ -9144,7 +15256,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9154,38 +15266,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -9198,14 +15310,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -9213,47 +15325,34 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Percent = 0, }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + double expectedPercent = 0; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Percent = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9265,56 +15364,59 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Percent = 0, }; 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"; + double expectedPercent = 0; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Percent = 0, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + { + Percent = 0, }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9326,7 +15428,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9347,7 +15449,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9355,7 +15457,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9366,7 +15468,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9383,7 +15485,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9392,17 +15494,22 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9432,19 +15539,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9454,7 +15567,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9475,12 +15588,13 @@ 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.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9494,6 +15608,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,12 +15623,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9543,13 +15663,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 ); @@ -9560,12 +15681,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9595,13 +15721,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 ); @@ -9609,13 +15736,18 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9625,7 +15757,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9646,12 +15778,13 @@ 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.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9668,6 +15801,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9682,12 +15816,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9717,6 +15856,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9727,12 +15867,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9758,6 +15903,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,12 +15914,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9782,12 +15934,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9801,6 +15958,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9827,6 +15985,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,12 +15996,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9855,43 +16020,99 @@ 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::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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput copied = new( + model + ); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; value.Validate(); } @@ -9902,7 +16123,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9912,38 +16133,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -9956,14 +16177,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -9971,38 +16192,43 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + 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 ); @@ -10014,104 +16240,129 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + 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); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", + UnitRatingKey = "x", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + 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 OptionalNonNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", + UnitRatingKey = "x", }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", + UnitRatingKey = "x", - // Null should be interpreted as omitted for these properties - Prorated = null, + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10123,7 +16374,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10144,7 +16395,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10152,7 +16403,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10163,7 +16414,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10180,7 +16431,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10189,164 +16440,171 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase +public class BillingCycleAlignmentTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void 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::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentID = "h74gfhdjvn7ujokd", }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; - string expectedItemID = "item_id"; - 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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig 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::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + AdjustmentID = "h74gfhdjvn7ujokd", }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentID = "h74gfhdjvn7ujokd", }; - 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.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + AdjustmentID = "h74gfhdjvn7ujokd", + }; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10357,535 +16615,591 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; - string expectedItemID = "item_id"; - 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() + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedPriceID, deserialized.PriceID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; + + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ExternalPriceID = null, + PriceID = null, }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = null, + PriceID = null, }; - 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.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase +{ [Fact] - public void Validation_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment { - 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() + Adjustment = new NewPercentageDiscount() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesAdjustmentID = "replaces_adjustment_id", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }; - model.Validate(); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + 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(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase { - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue - ) + [Fact] + public void NewPercentageDiscountValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > value = rawValue; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; value.Validate(); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void NewUsageDiscountValidationWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, + }; + value.Validate(); } - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue - ) + [Fact] + public void NewAmountDiscountValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; + value.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewMinimumValidationWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewMaximumValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - Percent = 0, + 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, }; - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, model.Percent); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewPercentageDiscountSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - Percent = 0, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - - 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 NewUsageDiscountSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - Percent = 0, + 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(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, deserialized.Percent); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig - { - Percent = 0, - }; - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment 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(); - } + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - [Fact] - public void TieredValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig 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 NewMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10894,26 +17208,32 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10922,179 +17242,303 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + 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() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - Currency = "currency", - DimensionalPriceConfiguration = new() + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + PriceID = "h74gfhdjvn7ujokd", + }; + + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DurationUnit = CustomExpirationDurationUnit.Day, }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PerUnitCostBasis = "per_unit_cost_basis", }; - - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + List expectedDiscounts = + [ 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() + 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() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + { "foo", JsonSerializer.SerializeToElement("bar") }, }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() + string expectedMinimumAmount = "1.23"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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 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, 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(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(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.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); - Assert.Equal(value, model.Metadata[item.Key]); + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - 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 ); @@ -11105,180 +17549,306 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - 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); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - 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", + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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 = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + { "foo", JsonSerializer.SerializeToElement("bar") }, }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "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(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(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.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.NotNull(deserialized.MetricParameterOverrides); + Assert.Equal( + expectedMetricParameterOverrides.Count, + deserialized.MetricParameterOverrides.Count + ); + foreach (var item in expectedMetricParameterOverrides) { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + Assert.True(deserialized.MetricParameterOverrides.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); } [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", }; model.Validate(); @@ -11287,63 +17857,37 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ReplacesPriceID = "replaces_price_id", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.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.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.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::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ReplacesPriceID = "replaces_price_id", }; model.Validate(); @@ -11352,1033 +17896,2138 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ReplacesPriceID = "replaces_price_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, + AllocationPrice = null, + Discounts = 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")); + 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.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.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::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ReplacesPriceID = "replaces_price_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, + AllocationPrice = null, + Discounts = null, ExternalPriceID = null, FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + Price = null, + PriceID = null, }; model.Validate(); } -} - -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 - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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", + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice copied = new(model); + + Assert.Equal(model, copied); } +} - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue - ) +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewSubscriptionTieredValidationWorks() { - 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); - - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionBulkValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkPrice() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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", }; - - 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); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void BulkWithFiltersValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + BulkWithFiltersConfig = new() + { + 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", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionPackageValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionPackagePrice() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = 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 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); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixPrice() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - UnitRatingKey = "x", + 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", }; - - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionTieredPackageValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() { - UnitRatingKey = "x", + 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", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionTieredWithMinimumValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - UnitRatingKey = "x", + 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", + }; + value.Validate(); + } - DefaultUnitRate = null, - GroupingKey = null, + [Fact] + public void NewSubscriptionGroupedTieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - 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 NewSubscriptionTieredPackageWithMinimumValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; value.Validate(); } [Fact] - public void TieredValidationWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + 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", }; value.Validate(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void MatrixWithThresholdDiscountsValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - FirstUnit = 0, + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", - LastUnit = 0, + SecondDimensionValue = "second_dimension_value", }, - ] - ), + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 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 - { - 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( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void TieredWithProrationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - AdjustmentID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void Validation_Works() + public void NewSubscriptionUnitWithProrationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - AdjustmentID = "h74gfhdjvn7ujokd", - }; - - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedAllocationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionBulkWithProrationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedPriceID, deserialized.PriceID); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + 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", + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; - - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; - - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { - 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() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + 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", + }; + value.Validate(); + } - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + [Fact] + public void CumulativeGroupedAllocationValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + value.Validate(); } [Fact] - public void Validation_Works() + public void DailyCreditAllowanceValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - model.Validate(); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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(); } -} -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void MeteredAllowanceValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_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", }; value.Validate(); } [Fact] - public void NewUsageDiscountValidationWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.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", }; value.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void PercentValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.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", }; value.Validate(); } [Fact] - public void NewMinimumValidationWorks() + public void EventOutputValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Name = "Annual fee", + BillableMetricID = "billable_metric_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 = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.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", }; value.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.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 = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.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", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 ); @@ -12387,32 +20036,51 @@ public void NewPercentageDiscountSerializationRoundtripWorks() } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkPrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12421,32 +20089,59 @@ public void NewUsageDiscountSerializationRoundtripWorks() } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + BulkWithFiltersConfig = new() + { + 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", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12455,33 +20150,51 @@ public void NewAmountDiscountSerializationRoundtripWorks() } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionPackagePrice() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12490,92 +20203,86 @@ public void NewMinimumSerializationRoundtripWorks() } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.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", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }, - ], - 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() @@ -12604,58 +20311,39 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + 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() @@ -12684,77 +20372,112 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string expectedPriceID = "h74gfhdjvn7ujokd"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + 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 = 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", - }, - Discounts = - [ - new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewSubscriptionGroupedTieredSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ], - 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, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12783,72 +20506,50 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; - - 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::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12877,66 +20578,37 @@ 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); + }; + string element = JsonSerializer.Serialize(value, 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() + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12965,77 +20637,32 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string expectedPriceID = "h74gfhdjvn7ujokd"; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13064,121 +20691,41 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; - - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13207,35 +20754,58 @@ public void NewSubscriptionUnitValidationWorks() 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 NewSubscriptionTieredValidationWorks() + public void MatrixWithThresholdDiscountsSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - FirstUnit = 0, + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", - LastUnit = 0, + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - Prorated = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13264,23 +20834,33 @@ public void NewSubscriptionTieredValidationWorks() 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 NewSubscriptionBulkValidationWorks() + public void TieredWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13309,30 +20889,90 @@ public void NewSubscriptionBulkValidationWorks() 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 BulkWithFiltersValidationWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - 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 element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13362,23 +21002,37 @@ public void BulkWithFiltersValidationWorks() 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 NewSubscriptionPackageValidationWorks() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.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::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13407,30 +21061,37 @@ public void NewSubscriptionPackageValidationWorks() 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 NewSubscriptionMatrixValidationWorks() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13460,32 +21121,51 @@ public void NewSubscriptionMatrixValidationWorks() 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 NewSubscriptionThresholdTotalAmountValidationWorks() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - ConsumptionTable = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], - Prorate = true, }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13514,31 +21194,37 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() 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 NewSubscriptionTieredPackageValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + 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() @@ -13567,43 +21253,44 @@ public void NewSubscriptionTieredPackageValidationWorks() 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 NewSubscriptionTieredWithMinimumValidationWorks() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + MatrixWithDisplayNameConfig = new() { - Tiers = + Dimension = "dimension", + UnitAmounts = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", + DimensionValue = "dimension_value", + DisplayName = "display_name", UnitAmount = "unit_amount", }, ], - HideZeroAmountTiers = true, - Prorate = true, }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13632,30 +21319,40 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() 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 NewSubscriptionGroupedTieredValidationWorks() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { GroupingKey = "x", + PackageSize = "package_size", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13685,42 +21382,41 @@ public void NewSubscriptionGroupedTieredValidationWorks() 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 NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + MaxGroupTieredPackageConfig = new() { - PackageSize = 0, + GroupingKey = "x", + PackageSize = "package_size", Tiers = [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, + 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() @@ -13749,28 +21445,48 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() 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 NewSubscriptionPackageWithAllocationValidationWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - PackageWithAllocationConfig = new() + ScalableMatrixWithUnitPricingConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + FirstDimension = "first_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, @@ -13800,24 +21516,51 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() 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 NewSubscriptionUnitWithPercentValidationWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + 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() @@ -13846,32 +21589,43 @@ public void NewSubscriptionUnitWithPercentValidationWorks() 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 NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + DimensionValues = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], + Group = "group", }, + ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13901,25 +21655,37 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() 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 TieredWithProrationValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13948,24 +21714,41 @@ public void TieredWithProrationValidationWorks() 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 NewSubscriptionUnitWithProrationValidationWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13994,28 +21777,38 @@ public void NewSubscriptionUnitWithProrationValidationWorks() 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 NewSubscriptionGroupedAllocationValidationWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - Allocation = "allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14045,28 +21838,35 @@ public void NewSubscriptionGroupedAllocationValidationWorks() 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 NewSubscriptionBulkWithProrationValidationWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14096,30 +21896,31 @@ public void NewSubscriptionBulkWithProrationValidationWorks() 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 NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void PercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14148,42 +21949,35 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() 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 NewSubscriptionGroupedWithMeteredMinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], + Assert.Equal(value, deserialized); + } + + [Fact] + public void EventOutputSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14213,27 +22007,40 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() 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); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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", @@ -14264,35 +22071,108 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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, + }; + 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + BulkWithFiltersConfig = new() { - Dimension = "dimension", - UnitAmounts = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14322,32 +22202,39 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = 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 NewSubscriptionGroupedTieredPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14377,32 +22264,119 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = 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); + + 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, + }; + 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 NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14432,162 +22406,212 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + BulkWithFiltersConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", }; - 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 NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + 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::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = 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 = + 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, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + BulkWithFiltersConfig = new() { - DimensionValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Group = "group", }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14617,647 +22641,564 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); + } +} + +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" }, + ], + }; + + string json = 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::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 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PropertyKey = "x", + PropertyValue = "x", }; - value.Validate(); + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ [Fact] - public void MinimumValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - value.Validate(); + + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void PercentValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", }; - value.Validate(); + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void EventOutputValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceTest + : 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 + ) { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() - { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + // 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 BulkWithFiltersSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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 NewSubscriptionPackageSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -15266,96 +23207,75 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = + ConversionRateType = 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 = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsTest + : TestBase +{ [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", + FirstDimensionValue = "first_dimension_value", UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], - HideZeroAmountTiers = true, - Prorate = true, }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15384,109 +23304,150 @@ 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); - } - [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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"; - Assert.Equal(value, deserialized); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + model.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - PackageSize = 0, - Tiers = + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }, ], }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15515,36 +23476,59 @@ 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); + + 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 NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15573,92 +23557,160 @@ 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); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig expectedMatrixWithThresholdDiscountsConfig = + new() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "matrix_with_threshold_discounts" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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"; - Assert.Equal(value, deserialized); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal( + expectedMatrixWithThresholdDiscountsConfig, + deserialized.MatrixWithThresholdDiscountsConfig + ); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixWithThresholdDiscountsConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], + FirstDimension = "first_dimension", MatrixValues = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, ], }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15688,85 +23740,308 @@ 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); + model.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.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() + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + ItemID = "item_id", + MatrixWithThresholdDiscountsConfig = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + MatrixWithThresholdDiscountsConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = + "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = + "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15795,931 +24070,1047 @@ 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); + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadenceTest + : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, model.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, model.SecondDimension); + Assert.NotNull(model.ThresholdDiscountGroups); + Assert.Equal(expectedThresholdDiscountGroups.Count, model.ThresholdDiscountGroups.Count); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal(expectedThresholdDiscountGroups[i], model.ThresholdDiscountGroups[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedDefaultUnitAmount = "default_unit_amount"; + string expectedFirstDimension = "first_dimension"; + List expectedMatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ]; + string expectedSecondDimension = "second_dimension"; + List expectedThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ]; + + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedFirstDimension, deserialized.FirstDimension); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); + Assert.NotNull(deserialized.ThresholdDiscountGroups); + Assert.Equal( + expectedThresholdDiscountGroups.Count, + deserialized.ThresholdDiscountGroups.Count + ); + for (int i = 0; i < expectedThresholdDiscountGroups.Count; i++) + { + Assert.Equal( + expectedThresholdDiscountGroups[i], + deserialized.ThresholdDiscountGroups[i] + ); + } } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.ThresholdDiscountGroups); + Assert.False(model.RawData.ContainsKey("threshold_discount_groups")); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void OptionalNonNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + + // Null should be interpreted as omitted for these properties + ThresholdDiscountGroups = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.SecondDimension); + Assert.False(model.RawData.ContainsKey("second_dimension")); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + Assert.Null(model.SecondDimension); + Assert.True(model.RawData.ContainsKey("second_dimension")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + + SecondDimension = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + { + DefaultUnitAmount = "default_unit_amount", + FirstDimension = "first_dimension", + MatrixValues = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }, + ], + SecondDimension = "second_dimension", + ThresholdDiscountGroups = + [ + new() + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }, + ], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + string expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, model.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, model.SecondDimensionValue); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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 NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - 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 expectedFirstDimensionValue = "first_dimension_value"; + string expectedUnitAmount = "unit_amount"; + string expectedSecondDimensionValue = "second_dimension_value"; + + Assert.Equal(expectedFirstDimensionValue, deserialized.FirstDimensionValue); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedSecondDimensionValue, deserialized.SecondDimensionValue); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + Assert.Null(model.SecondDimensionValue); + Assert.False(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + Assert.Null(model.SecondDimensionValue); + Assert.True(model.RawData.ContainsKey("second_dimension_value")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + + SecondDimensionValue = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + { + FirstDimensionValue = "first_dimension_value", + UnitAmount = "unit_amount", + SecondDimensionValue = "second_dimension_value", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupTest + : TestBase +{ [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + string expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + model.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + model.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, model.CellCoordinates); + Assert.Equal(expectedThresholdAmount, model.ThresholdAmount); + Assert.Equal(expectedDescription, model.Description); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + 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 MinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - 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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", }; - 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 expectedAboveThresholdDiscountPercentage = "above_threshold_discount_percentage"; + string expectedBelowThresholdDiscountPercentage = "below_threshold_discount_percentage"; + string expectedCellCoordinates = "cell_coordinates"; + string expectedThresholdAmount = "threshold_amount"; + string expectedDescription = "description"; + + Assert.Equal( + expectedAboveThresholdDiscountPercentage, + deserialized.AboveThresholdDiscountPercentage + ); + Assert.Equal( + expectedBelowThresholdDiscountPercentage, + deserialized.BelowThresholdDiscountPercentage + ); + Assert.Equal(expectedCellCoordinates, deserialized.CellCoordinates); + Assert.Equal(expectedThresholdAmount, deserialized.ThresholdAmount); + Assert.Equal(expectedDescription, deserialized.Description); } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + Assert.Null(model.Description); + Assert.False(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + Assert.Null(model.Description); + Assert.True(model.RawData.ContainsKey("description")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + + Description = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + { + AboveThresholdDiscountPercentage = "above_threshold_discount_percentage", + BelowThresholdDiscountPercentage = "below_threshold_discount_percentage", + CellCoordinates = "cell_coordinates", + ThresholdAmount = "threshold_amount", + Description = "description", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig 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); + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedUnitConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16728,55 +25119,26 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 ); @@ -16785,27 +25147,21 @@ public void EventOutputSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16834,28 +25190,21 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -16864,7 +25213,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16885,14 +25234,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); @@ -16904,6 +25254,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -16919,21 +25270,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16962,13 +25307,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 ); @@ -16980,21 +25326,15 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17023,36 +25363,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( + 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 + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -17061,7 +25394,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17082,14 +25415,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); @@ -17104,6 +25438,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -17119,21 +25454,15 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17162,6 +25491,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17173,21 +25503,15 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -17212,6 +25536,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17222,21 +25548,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -17246,21 +25566,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17273,6 +25587,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17299,6 +25614,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -17309,21 +25626,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17336,251 +25647,212 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = 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" }, - ], - }; - - 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + 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(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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [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 + ) { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - 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< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + > value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData( + Subscriptions::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 + ) { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - 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< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + > value = rawValue; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + > + >(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 Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + 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); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 ); @@ -17592,211 +25864,161 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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 expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - UnitAmount = "unit_amount", + Tiers = [new() { TierLowerBound = "tier_lower_bound", 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", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest + : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - model.Validate(); - } -} + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); -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(); + Assert.Equal(model, deserialized); } [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; + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_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); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17808,7 +26030,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17829,7 +26051,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17837,7 +26059,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17848,7 +26070,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17865,7 +26087,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17874,21 +26096,26 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26144,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26175,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17960,14 +26196,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( + 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); @@ -17979,6 +26219,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26235,19 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26276,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 +26295,19 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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,13 +26336,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 ); @@ -18100,14 +26351,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); 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 +26375,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18137,14 +26396,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( + 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); @@ -18159,6 +26422,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26438,19 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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 +26479,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18222,15 +26491,19 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -18255,6 +26528,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26540,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -18283,15 +26562,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -18304,6 +26587,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18330,6 +26614,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -18340,15 +26626,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -18361,44 +26651,101 @@ 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::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 SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -18409,7 +26756,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -18419,38 +26766,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -18463,14 +26810,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -18478,42 +26825,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + 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 ); @@ -18525,130 +26877,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + 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); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } -} - -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() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + 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 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", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18660,7 +26956,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18681,7 +26977,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18689,7 +26985,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18700,7 +26996,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18717,7 +27013,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18726,23 +27022,23 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -18774,26 +27070,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::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -18804,7 +27101,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18825,13 +27122,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -18847,6 +27145,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,16 +27161,16 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - 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", @@ -18903,13 +27202,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,16 +27221,16 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - 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", @@ -18962,13 +27262,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,20 +27277,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" + "cumulative_grouped_allocation" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19000,7 +27301,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19021,13 +27322,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -19046,6 +27348,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,16 +27364,16 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - 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", @@ -19102,6 +27405,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19113,16 +27417,16 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - 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", @@ -19150,6 +27454,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,16 +27466,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - 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", @@ -19182,16 +27488,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - 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", @@ -19207,6 +27513,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19233,6 +27540,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,16 +27552,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - 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", @@ -19268,44 +27577,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::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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -19316,7 +27682,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -19326,38 +27692,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -19370,14 +27736,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -19385,47 +27751,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19437,56 +27803,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedUnitAmount = "unit_amount"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19498,7 +27882,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19519,7 +27903,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19527,7 +27911,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19538,7 +27922,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19555,7 +27939,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19564,23 +27948,27 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -19612,27 +28000,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::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19642,7 +28030,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19663,14 +28051,12 @@ 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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -19685,6 +28071,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +28087,20 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -19741,13 +28132,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 +28151,20 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -19800,13 +28196,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,21 +28211,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19838,7 +28234,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19859,14 +28255,12 @@ 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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -19884,6 +28278,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +28294,20 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -19940,6 +28339,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19951,16 +28351,20 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -19988,6 +28392,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28404,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -20020,16 +28430,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -20045,6 +28459,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20071,6 +28486,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +28498,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -20106,44 +28527,105 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > value = rawValue; value.Validate(); } @@ -20154,7 +28636,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20164,38 +28646,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -20208,14 +28690,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -20223,29 +28705,171 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, model.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, model.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, model.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], model.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, model.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, model.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], model.MatrixValues[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string json = 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedDailyAllowance, deserialized.DailyAllowance); + Assert.Equal(expectedDefaultUnitAmount, deserialized.DefaultUnitAmount); + Assert.Equal(expectedDimensions.Count, deserialized.Dimensions.Count); + for (int i = 0; i < expectedDimensions.Count; i++) + { + Assert.Equal(expectedDimensions[i], deserialized.Dimensions[i]); + } + Assert.Equal(expectedEventDayProperty, deserialized.EventDayProperty); + Assert.Equal(expectedMatrixValues.Count, deserialized.MatrixValues.Count); + for (int i = 0; i < expectedMatrixValues.Count; i++) + { + Assert.Equal(expectedMatrixValues[i], deserialized.MatrixValues[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, model.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], model.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -20253,17 +28877,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20275,30 +28897,28 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], 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"; + List expectedDimensionValues = ["string"]; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedDimensionValues.Count, deserialized.DimensionValues.Count); + for (int i = 0; i < expectedDimensionValues.Count; i++) + { + Assert.Equal(expectedDimensionValues[i], deserialized.DimensionValues[i]); + } Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -20306,25 +28926,39 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + DimensionValues = ["string"], UnitAmount = "unit_amount", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20336,7 +28970,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20357,7 +28991,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20365,7 +28999,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20376,7 +29010,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20393,7 +29027,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20402,59 +29036,77 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceTest : 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20464,7 +29116,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20485,12 +29137,13 @@ 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.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -20504,6 +29157,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +29172,58 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 +29234,58 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 +29293,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = + new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20635,7 +29317,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20656,12 +29338,13 @@ 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.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20678,6 +29361,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +29376,54 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 +29431,23 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -20768,6 +29471,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29482,23 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + }; model.Validate(); } @@ -20792,28 +29506,38 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "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 +29561,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +29572,131 @@ 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > value = rawValue; value.Validate(); } @@ -20912,7 +29707,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20922,38 +29717,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -20966,14 +29761,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -20981,39 +29776,55 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, model.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, model.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, model.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, model.ConsumptionDisplayName); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -21025,35 +29836,51 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; 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 expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAllowanceGroupingValue, deserialized.AllowanceGroupingValue); + Assert.Equal(expectedConsumptionGroupingValue, deserialized.ConsumptionGroupingValue); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedAllowanceDisplayName, deserialized.AllowanceDisplayName); + Assert.Equal(expectedConsumptionDisplayName, deserialized.ConsumptionDisplayName); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; model.Validate(); @@ -21063,22 +29890,30 @@ public void Validation_Works() public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); @@ -21088,41 +29923,71 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.AllowanceDisplayName); + Assert.False(model.RawData.ContainsKey("allowance_display_name")); + Assert.Null(model.ConsumptionDisplayName); + Assert.False(model.RawData.ContainsKey("consumption_display_name")); } [Fact] public void OptionalNonNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig { - MinimumAmount = "minimum_amount", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", // Null should be interpreted as omitted for these properties - Prorated = null, + AllowanceDisplayName = null, + ConsumptionDisplayName = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21134,7 +29999,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21155,7 +30020,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21163,7 +30028,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21174,7 +30039,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21191,7 +30056,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21240,6 +30105,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21283,6 +30149,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 +30169,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +30219,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21403,6 +30272,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21454,6 +30324,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 +30347,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +30397,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21566,6 +30439,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30484,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21635,6 +30511,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +30541,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 +30777,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 +30924,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22028,6 +30973,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 +30993,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +31049,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22160,6 +31108,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22216,6 +31165,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 +31188,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +31244,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22340,6 +31292,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31349,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -22421,6 +31376,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +31412,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 +31729,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..a9b76836c 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() @@ -440,6 +442,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -487,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() @@ -575,6 +584,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -595,6 +605,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -642,9 +653,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 +803,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1059,6 +1081,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1079,6 +1102,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1126,6 +1150,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 +1242,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1232,6 +1263,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1279,9 +1311,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 +1483,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1718,6 +1761,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1738,6 +1782,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1785,6 +1830,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 +1924,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1893,6 +1945,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1940,9 +1993,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 +2163,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2377,6 +2441,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2397,6 +2462,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2444,6 +2510,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 +2604,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2552,6 +2625,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2599,9 +2673,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 +2830,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3023,6 +3108,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3043,6 +3129,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3090,6 +3177,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 +3269,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3196,6 +3290,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3243,9 +3338,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 +3510,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3682,6 +3788,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3702,6 +3809,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3749,6 +3857,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 +3951,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3857,6 +3972,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3904,9 +4020,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 +4051,680 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..2824d7fd8 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() @@ -426,6 +428,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -473,6 +476,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, ], Product = new() @@ -557,6 +566,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -577,6 +587,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -624,9 +635,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 +777,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1030,6 +1052,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1050,6 +1073,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1097,6 +1121,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 +1204,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1194,6 +1225,7 @@ public void FieldRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1241,9 +1273,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 +1480,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1714,6 +1757,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1734,6 +1778,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1781,6 +1826,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 +1916,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1885,6 +1937,7 @@ public void SerializationRoundtrip_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -1932,9 +1985,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 +2138,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2351,6 +2415,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2371,6 +2436,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2418,6 +2484,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 +2574,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2522,6 +2595,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -2569,9 +2643,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 +2792,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2982,6 +3067,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3002,6 +3088,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3049,6 +3136,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 +3219,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3146,6 +3240,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3193,9 +3288,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 +3504,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3675,6 +3781,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3695,6 +3802,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3742,6 +3850,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 +3940,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3846,6 +3961,7 @@ public void Validation_Works() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, @@ -3893,9 +4009,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 +4037,660 @@ 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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, + InvoiceGroupingKey = "invoice_grouping_key", + 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..61d9286f8 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs @@ -59,9 +59,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/trigger_phase"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/trigger_phase"), + 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..936edb8c5 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_cancellation" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_cancellation" + ), + 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..13b43d7b7 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs @@ -32,11 +32,27 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_fixed_fee_quantity_updates" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_fixed_fee_quantity_updates" + ), + 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..e790fc7a7 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs @@ -28,11 +28,26 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_pending_plan_changes" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/unschedule_pending_plan_changes" + ), + 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..f3e006b50 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs @@ -121,13 +121,33 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri( - "https://api.withorb.com/v1/subscriptions/subscription_id/update_fixed_fee_quantity" - ), - url + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.withorb.com/v1/subscriptions/subscription_id/update_fixed_fee_quantity" + ), + 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..2e751387a 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs @@ -91,6 +91,29 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions/subscription_id"), url); + Assert.True( + TestBase.UrisEqual( + 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..2e142458e 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs @@ -67,11 +67,28 @@ public void Url_Works() var url = parameters.Url(new() { ApiKey = "My API Key" }); - Assert.Equal( - new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/update_trial"), - url + Assert.True( + TestBase.UrisEqual( + new Uri("https://api.withorb.com/v1/subscriptions/subscription_id/update_trial"), + 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..36d0e0f90 --- /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 = "x", Name = "x" }, + 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..4bc81af54 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,60 @@ public async Task Create_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", }, + LicenseAllocationPrice = new() + { + Cadence = Plans::Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + ModelType = Plans::ModelType.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", + }, PlanPhaseOrder = 0, PriceValue = new NewPlanUnitPrice() { @@ -79,6 +132,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.Tests/TestBase.cs b/src/Orb.Tests/TestBase.cs index f0dddb84a..52353b805 100644 --- a/src/Orb.Tests/TestBase.cs +++ b/src/Orb.Tests/TestBase.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using Orb; namespace Orb.Tests; @@ -16,4 +18,42 @@ public TestBase() ApiKey = "My API Key", }; } + + internal static bool UrisEqual(Uri uri1, Uri uri2) + { + if ( + uri1.Scheme != uri2.Scheme + || uri1.Host != uri2.Host + || uri1.Port != uri2.Port + || uri1.AbsolutePath != uri2.AbsolutePath + ) + { + return false; + } + + var query1 = ParseQueryString(uri1.Query); + var query2 = ParseQueryString(uri2.Query); + + return Enumerable.SequenceEqual(query1, query2); + } + + static SortedDictionary ParseQueryString(string query) + { + var ret = new SortedDictionary(StringComparer.Ordinal); + + if (string.IsNullOrEmpty(query)) + return ret; + + var pairs = query.TrimStart('?').Split(['&'], StringSplitOptions.RemoveEmptyEntries); + + foreach (var pair in pairs) + { + var parts = pair.Split(['&'], 2); + var key = Uri.UnescapeDataString(parts[0]); + var value = parts.Length > 1 ? Uri.UnescapeDataString(parts[1]) : string.Empty; + ret[key] = value; + } + + return ret; + } } 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..93e0b8e82 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 . @@ -21,8 +21,16 @@ public struct ClientOptions() /// /// The HTTP client to use for making requests in the SDK. + /// + /// Note: The HttpClient has a built-in timeout, which defaults to 100 seconds. + /// When passing a custom HttpClient, this timeout may conflict with the SDK's + /// own timeout handler and cause premature cancellation. /// - public HttpClient HttpClient { get; set; } = new(); + public HttpClient HttpClient { get; set; } = + new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available }) + { + Timeout = global::System.Threading.Timeout.InfiniteTimeSpan, + }; Lazy _baseUrl = new(() => Environment.GetEnvironmentVariable("ORB_BASE_URL") ?? EnvironmentUrl.Production @@ -71,7 +79,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 +89,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..b311048fd 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; @@ -319,6 +320,14 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter< + string, + MatrixWithThresholdDiscountsCompositePriceFilterOperator + >(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -398,11 +407,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(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -432,13 +446,23 @@ 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< + string, + Beta::ReplacePricePriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter(), new ApiEnumConverter< string, @@ -448,17 +472,34 @@ 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< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceModelType + >(), new ApiEnumConverter(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePricePriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, ExternalPlanID::ReplacePricePriceTieredWithProrationCadence @@ -471,10 +512,18 @@ protected ModelBase(ModelBase modelBase) string, ExternalPlanID::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePricePriceMeteredAllowanceCadence + >(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter< @@ -569,6 +618,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 +651,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -596,10 +658,14 @@ 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(), @@ -618,21 +684,29 @@ 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< string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersCadence >(), + new ApiEnumConverter< + string, + Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence @@ -643,7 +717,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -822,14 +900,20 @@ 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< + string, + Subscriptions::ReplacePricePriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, Subscriptions::ReplacePricePriceTieredWithProrationCadence @@ -842,7 +926,11 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), + new ApiEnumConverter< + string, + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -851,6 +939,10 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), + new ApiEnumConverter< + string, + Subscriptions::PriceModelMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence @@ -859,7 +951,8 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::PriceModelCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -871,6 +964,10 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence @@ -885,7 +982,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -900,6 +1001,10 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence @@ -914,7 +1019,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -930,9 +1039,13 @@ 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< string, @@ -954,6 +1067,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..1119bb6fd 100644 --- a/src/Orb/Core/ParamsBase.cs +++ b/src/Orb/Core/ParamsBase.cs @@ -17,7 +17,7 @@ public abstract record class ParamsBase static ParamsBase() { var runtime = GetRuntime(); - defaultHeaders = new Dictionary + var headers = new Dictionary { ["User-Agent"] = GetUserAgent(), ["X-Stainless-Arch"] = GetOSArch(), @@ -27,6 +27,21 @@ static ParamsBase() ["X-Stainless-Runtime"] = runtime.Name, ["X-Stainless-Runtime-Version"] = runtime.Version, }; + + var customHeadersEnv = Environment.GetEnvironmentVariable("ORB_CUSTOM_HEADERS"); + if (customHeadersEnv != null) + { + foreach (var line in customHeadersEnv.Split('\n')) + { + var colon = line.IndexOf(':'); + if (colon >= 0) + { + headers[line.Substring(0, colon).Trim()] = line.Substring(colon + 1).Trim(); + } + } + } + + defaultHeaders = headers; } private protected JsonDictionary _rawQueryData = new(); @@ -151,9 +166,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 +199,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 +218,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 +259,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 +277,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..2e7e00581 100644 --- a/src/Orb/Models/Alerts/Alert.cs +++ b/src/Orb/Models/Alerts/Alert.cs @@ -176,6 +176,83 @@ 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); } + } + + /// + /// Filters scoping which prices are included in grouped cost alert evaluation. + /// + public IReadOnlyList? PriceFilters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "price_filters" + ); + } + init + { + this._rawData.Set?>( + "price_filters", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Per-group threshold overrides. Each override maps a specific combination of + /// grouping_keys values to a replacement threshold list. Only present for grouped + /// cost alerts that have at least one override. + /// + public IReadOnlyList? ThresholdOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_overrides" + ); + } + init + { + this._rawData.Set?>( + "threshold_overrides", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + /// public override void Validate() { @@ -196,12 +273,25 @@ public override void Validate() { item.Validate(); } + _ = this.GroupingKeys; + this.LicenseType?.Validate(); + foreach (var item in this.PriceFilters ?? []) + { + item.Validate(); + } + foreach (var item in this.ThresholdOverrides ?? []) + { + item.Validate(); + } } public Alert() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Alert(Alert alert) : base(alert) { } +#pragma warning restore CS8618 public Alert(IReadOnlyDictionary rawData) { @@ -254,8 +344,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 +446,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 +490,7 @@ public enum AlertType CreditBalanceRecovered, UsageExceeded, CostExceeded, + LicenseBalanceThresholdReached, } sealed class AlertTypeConverter : JsonConverter @@ -411,6 +508,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 +528,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 +579,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 +613,361 @@ 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); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AlertPriceFilter : 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 AlertPriceFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AlertPriceFilter(AlertPriceFilter alertPriceFilter) + : base(alertPriceFilter) { } +#pragma warning restore CS8618 + + public AlertPriceFilter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AlertPriceFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AlertPriceFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AlertPriceFilterFromRaw : IFromRawJson +{ + /// + public AlertPriceFilter FromRawUnchecked(IReadOnlyDictionary rawData) => + AlertPriceFilter.FromRawUnchecked(rawData); +} + +/// +/// The property of the price to filter on. +/// +[JsonConverter(typeof(AlertPriceFilterFieldConverter))] +public enum AlertPriceFilterField +{ + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class AlertPriceFilterFieldConverter : JsonConverter +{ + public override AlertPriceFilterField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "price_id" => AlertPriceFilterField.PriceID, + "item_id" => AlertPriceFilterField.ItemID, + "price_type" => AlertPriceFilterField.PriceType, + "currency" => AlertPriceFilterField.Currency, + "pricing_unit_id" => AlertPriceFilterField.PricingUnitID, + _ => (AlertPriceFilterField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AlertPriceFilterField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AlertPriceFilterField.PriceID => "price_id", + AlertPriceFilterField.ItemID => "item_id", + AlertPriceFilterField.PriceType => "price_type", + AlertPriceFilterField.Currency => "currency", + AlertPriceFilterField.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(AlertPriceFilterOperatorConverter))] +public enum AlertPriceFilterOperator +{ + Includes, + Excludes, +} + +sealed class AlertPriceFilterOperatorConverter : JsonConverter +{ + public override AlertPriceFilterOperator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => AlertPriceFilterOperator.Includes, + "excludes" => AlertPriceFilterOperator.Excludes, + _ => (AlertPriceFilterOperator)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AlertPriceFilterOperator value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AlertPriceFilterOperator.Includes => "includes", + AlertPriceFilterOperator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// A per-group threshold override on a grouped cost alert. +/// +/// An empty `thresholds` list means the group is silenced (never fires). A +/// non-empty list fully replaces the default thresholds for that group. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class AlertThresholdOverride : JsonModel +{ + /// + /// The values of the grouping keys that identify this group. The list length + /// matches the alert's grouping_keys. + /// + public required IReadOnlyList GroupValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("group_values"); + } + init + { + this._rawData.Set>( + "group_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The thresholds applied to this group. An empty list means the group is silenced. + /// + public required IReadOnlyList Thresholds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("thresholds"); + } + init + { + this._rawData.Set>( + "thresholds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupValues; + foreach (var item in this.Thresholds) + { + item.Validate(); + } + } + + public AlertThresholdOverride() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AlertThresholdOverride(AlertThresholdOverride alertThresholdOverride) + : base(alertThresholdOverride) { } +#pragma warning restore CS8618 + + public AlertThresholdOverride(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + AlertThresholdOverride(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static AlertThresholdOverride FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class AlertThresholdOverrideFromRaw : IFromRawJson +{ + /// + public AlertThresholdOverride FromRawUnchecked( + IReadOnlyDictionary rawData + ) => AlertThresholdOverride.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..397510fab 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,72 @@ public string? MetricID init { this._rawBodyData.Set("metric_id", value); } } + /// + /// Filters to scope which prices are included in grouped cost alert evaluation. + /// Supports filtering by price_id, item_id, or price_type with includes/excludes + /// operators. Only applicable when grouping_keys is set. + /// + public IReadOnlyList? PriceFilters + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>( + "price_filters" + ); + } + init + { + this._rawBodyData.Set?>( + "price_filters", + value == null ? null : ImmutableArray.ToImmutableArray(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); } + } + + /// + /// Per-group threshold overrides. Each override maps a specific combination of + /// grouping_keys values to a list of thresholds that fully replaces the default + /// thresholds for that group. An empty thresholds list silences the group. Groups + /// without an override use the default thresholds. Only applicable when grouping_keys + /// is set. + /// + public IReadOnlyList? ThresholdOverrides + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>( + "threshold_overrides" + ); + } + init + { + this._rawBodyData.Set?>( + "threshold_overrides", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + public AlertCreateForSubscriptionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertCreateForSubscriptionParams( AlertCreateForSubscriptionParams alertCreateForSubscriptionParams ) @@ -93,6 +180,7 @@ AlertCreateForSubscriptionParams alertCreateForSubscriptionParams this._rawBodyData = new(alertCreateForSubscriptionParams._rawBodyData); } +#pragma warning restore CS8618 public AlertCreateForSubscriptionParams( IReadOnlyDictionary rawHeaderData, @@ -110,29 +198,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 +283,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -210,3 +337,286 @@ JsonSerializerOptions options ); } } + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceFilter : 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 PriceFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceFilter(PriceFilter priceFilter) + : base(priceFilter) { } +#pragma warning restore CS8618 + + public PriceFilter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceFilter FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceFilterFromRaw : IFromRawJson +{ + /// + public PriceFilter FromRawUnchecked(IReadOnlyDictionary rawData) => + PriceFilter.FromRawUnchecked(rawData); +} + +/// +/// The property of the price to filter on. +/// +[JsonConverter(typeof(FieldConverter))] +public enum Field +{ + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class FieldConverter : JsonConverter +{ + public override Field Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, Field value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Should prices that match the filter be included or excluded. +/// +[JsonConverter(typeof(OperatorConverter))] +public enum Operator +{ + Includes, + Excludes, +} + +sealed class OperatorConverter : JsonConverter +{ + public override Operator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Operator.Includes => "includes", + Operator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Per-group threshold override on a grouped cost alert. +/// +/// - An empty `thresholds` list silences alerts for this group (never fires). +/// - A non-empty list fully replaces the default thresholds for this group. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdOverride : JsonModel +{ + /// + /// The values of the grouping keys that identify this group. The list length + /// must match the alert's grouping_keys, and values appear in the same order + /// as grouping_keys. + /// + public required IReadOnlyList GroupValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("group_values"); + } + init + { + this._rawData.Set>( + "group_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// The thresholds to apply to this group. An empty list silences alerts for this + /// group. A non-empty list fully replaces the default thresholds for this group. + /// + public required IReadOnlyList Thresholds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("thresholds"); + } + init + { + this._rawData.Set>( + "thresholds", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.GroupValues; + foreach (var item in this.Thresholds) + { + item.Validate(); + } + } + + public ThresholdOverride() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdOverride(ThresholdOverride thresholdOverride) + : base(thresholdOverride) { } +#pragma warning restore CS8618 + + public ThresholdOverride(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdOverride(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdOverride FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdOverrideFromRaw : IFromRawJson +{ + /// + public ThresholdOverride FromRawUnchecked(IReadOnlyDictionary rawData) => + ThresholdOverride.FromRawUnchecked(rawData); +} 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..9cca21d92 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,3986 +962,3961 @@ 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(JsonModelConverter))] +public sealed record class LicenseAllocationPrice : 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>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) ); } } - public string ItemID + /// + /// The pricing model type + /// + public required ApiEnum ModelType { 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.GetNotNullClass>("model_type"); } + init { this._rawData.Set("model_type", value); } } - public string Name + /// + /// The name of the price. + /// + public required 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, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); } + init { this._rawData.Set("name", value); } } - public string? BillableMetricID + /// + /// Configuration for unit pricing + /// + public required UnitConfig UnitConfig { 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.GetNotNullClass("unit_config"); } + init { this._rawData.Set("unit_config", value); } } - public bool? BilledInAdvance + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { 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("billable_metric_id"); } + init { this._rawData.Set("billable_metric_id", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { 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("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } + init { this._rawData.Set("billing_cycle_configuration", value); } } + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// 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, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("conversion_rate_config"); } + init { this._rawData.Set("conversion_rate_config", value); } } + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// public string? Currency { get { - 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("currency"); } + init { this._rawData.Set("currency", value); } } + /// + /// For dimensional price: specifies a price group and dimension values + /// 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, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// An alias for the price. + /// 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, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// public double? FixedPriceQuantity { get { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public string? InvoiceGroupingKey + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { get { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } + /// + /// Within each 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.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( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string? ReferenceID + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { get { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public Price(NewPlanUnitPrice value, JsonElement? element = null) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public Price(NewPlanTieredPrice 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 Price(NewPlanBulkPrice 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(); + } + this.ModelType.Validate(); + _ = 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 Price(global::Orb.Models.Beta.BulkWithFilters value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public LicenseAllocationPrice() { } - public Price(NewPlanPackagePrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocationPrice(LicenseAllocationPrice licenseAllocationPrice) + : base(licenseAllocationPrice) { } +#pragma warning restore CS8618 + + public LicenseAllocationPrice(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public Price(NewPlanMatrixPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocationPrice(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + /// + public static LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) +class LicenseAllocationPriceFromRaw : IFromRawJson +{ + /// + public LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseAllocationPrice.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), + }; } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : 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 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) + /// + /// 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 Price(global::Orb.Models.Beta.TieredWithProration 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 Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public LicenseAllocation() { } - public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 - public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocation(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value, - JsonElement? element = null + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData ) { - 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; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class LicenseAllocationFromRaw : IFromRawJson +{ + /// + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); +} - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +/// +/// The pricing model type +/// +[JsonConverter(typeof(ModelTypeConverter))] +public enum ModelType +{ + Unit, +} - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) +sealed class ModelTypeConverter : JsonConverter +{ + public override ModelType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unit" => ModelType.Unit, + _ => (ModelType)(-1), + }; } - public Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + ModelType value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + ModelType.Unit => "unit", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public Price(global::Orb.Models.Beta.Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) + JsonElement? _element = null; + + public JsonElement Json { - this.Value = value; - this._element = element; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - public Price(global::Orb.Models.Beta.Percent value, JsonElement? element = null) + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.EventOutput value, JsonElement? element = null) + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(JsonElement 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 . + /// 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 ConversionRateConfig" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.BulkWithFilters` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Beta.BulkWithFilters? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as global::Orb.Models.Beta.BulkWithFilters; - 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 ConversionRateConfig" + ), + }; } + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); + + public static implicit operator ConversionRateConfig(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 ConversionRateConfig" + ); + } + 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) - { - value = this.Value as NewPlanMatrixPrice; - return value != null; - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanThresholdTotalAmountPrice; - 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.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; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) + int VariantIndex() { - value = this.Value as NewPlanTieredWithMinimumPrice; - 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.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value +sealed class ConversionRateConfigConverter : JsonConverter +{ + public override ConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanGroupedTieredPrice; - 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 ConversionRateConfig(element); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) +/// +/// 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 { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 - ) + public string ItemID { - 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; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.TieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Beta.TieredWithProration? value - ) + public string Name { - value = this.Value as global::Orb.Models.Beta.TieredWithProration; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - 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; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.GroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Beta.GroupedWithMinMaxThresholds? value - ) + public double? ConversionRate { - value = this.Value as global::Orb.Models.Beta.GroupedWithMinMaxThresholds; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newPlanMinimumComposite: (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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public string? Currency { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newPlanMinimumComposite: (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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public string? ExternalPriceID { - 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; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.CumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Beta.CumulativeGroupedAllocation? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as global::Orb.Models.Beta.CumulativeGroupedAllocation; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoicingCycleConfiguration, + newPlanTiered: (x) => x.InvoicingCycleConfiguration, + newPlanBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newPlanPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMatrix: (x) => x.InvoicingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Beta.Minimum? value) + public string? LicenseTypeID { - value = this.Value as global::Orb.Models.Beta.Minimum; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } } - /// - /// Returns true and sets the 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 string? ReferenceID { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; - } + get + { + return Match( + newPlanUnit: (x) => x.ReferenceID, + newPlanTiered: (x) => x.ReferenceID, + newPlanBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newPlanPackage: (x) => x.ReferenceID, + newPlanMatrix: (x) => x.ReferenceID, + newPlanThresholdTotalAmount: (x) => x.ReferenceID, + newPlanTieredPackage: (x) => x.ReferenceID, + newPlanTieredWithMinimum: (x) => x.ReferenceID, + newPlanGroupedTiered: (x) => x.ReferenceID, + newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, + newPlanPackageWithAllocation: (x) => x.ReferenceID, + newPlanUnitWithPercent: (x) => x.ReferenceID, + newPlanMatrixWithAllocation: (x) => x.ReferenceID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (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(BulkWithFilters 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(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(DailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(MeteredAllowance 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(Percent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(EventOutput 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 . + /// 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` + /// if (instance.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out global::Orb.Models.Beta.Percent? value) + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - value = this.Value as global::Orb.Models.Beta.Percent; + 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 . + /// 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` + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Beta.EventOutput? value - ) + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - value = this.Value as global::Orb.Models.Beta.EventOutput; + value = this.Value as NewPlanTieredPrice; return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// 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. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// Consider using or if you need to handle every variant. /// /// /// - /// instance.Switch( - /// (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) => {...} - /// ); + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(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 - ) + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - switch (this.Value) - { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.BulkWithFilters 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.TieredWithProration 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.GroupedWithMinMaxThresholds 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.CumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.Minimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.Percent value: - percent(value); - break; - case global::Orb.Models.Beta.EventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException("Data did not match any variant of Price"); - } + value = this.Value as NewPlanBulkPrice; + return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `BulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) + { + value = this.Value as BulkWithFilters; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. /// /// /// - /// 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) => {...} - /// ); + /// if (instance.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(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 - ) + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - 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 - ), - 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"), - }; + value = this.Value as NewPlanPackagePrice; + return value != null; } - public static implicit operator global::Orb.Models.Beta.Price(NewPlanUnitPrice value) => - new(value); + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } - public static implicit operator global::Orb.Models.Beta.Price(NewPlanTieredPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanBulkPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.BulkWithFilters value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanPackagePrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanMatrixPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.TieredWithProration value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Minimum value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMinimumCompositePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Percent value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.EventOutput value - ) => new(value); + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance does not pass validation. - /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackage(out var value)) { + /// // `value` is of type `NewPlanTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public override void Validate() + public bool TryPickNewPlanTieredPackage( + [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + ) { - 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); + value = this.Value as NewPlanTieredPackagePrice; + return value != null; } - public virtual bool Equals(global::Orb.Models.Beta.Price? other) + /// + /// Returns true and sets the 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 + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + value = this.Value as NewPlanTieredWithMinimumPrice; + return value != null; } - public override int GetHashCode() + /// + /// Returns true and sets the 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 + ) { - return 0; + value = this.Value as NewPlanGroupedTieredPrice; + return value != null; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } -sealed class PriceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.Price? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } + value = this.Value as NewPlanPackageWithAllocationPrice; + return value != null; + } - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.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.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; + } - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value + ) + { + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `TieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + { + value = this.Value as TieredWithProration; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `GroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value + ) + { + value = this.Value as GroupedWithMinMaxThresholds; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + ) + { + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + return value != null; + } - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value + ) + { + value = this.Value as NewPlanCumulativeGroupedBulkPrice; + return value != null; + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `CumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out CumulativeGroupedAllocation? value + ) + { + value = this.Value as CumulativeGroupedAllocation; + return value != null; + } - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; + return value != null; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) + { + value = this.Value as MeteredAllowance; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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.Price(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.Price? value, - JsonSerializerOptions options - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `Percent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - JsonSerializer.Serialize(writer, value?.Json, options); + value = this.Value as Percent; + return value != null; } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFilters, - global::Orb.Models.Beta.BulkWithFiltersFromRaw - >) -)] -public sealed record class BulkWithFilters : JsonModel -{ /// - /// Configuration for bulk_with_filters pricing + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `EventOutput` + /// Console.WriteLine(value); + /// } + /// + /// /// - public required global::Orb.Models.Beta.BulkWithFiltersConfig BulkWithFiltersConfig + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } + value = this.Value as EventOutput; + return value != 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); } - } - - /// - /// The id of the item the price will be associated with. + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the 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) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// /// - public required string ItemID + 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + System::Action newPlanMinimumComposite, + System::Action percent, + System::Action eventOutput + ) { - get + switch (this.Value) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case BulkWithFilters 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 MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; + case TieredWithProration 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 GroupedWithMinMaxThresholds 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 CumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case Percent value: + percent(value); + break; + case EventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of Price"); } - init { this._rawData.Set("item_id", value); } } /// - /// The pricing model 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. + /// + /// + /// Thrown when the instance was 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) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// /// - public JsonElement ModelType + 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Func meteredAllowance, + System::Func newPlanMinimumComposite, + System::Func percent, + System::Func eventOutput + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + BulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), + TieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + }; } - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } + public static implicit operator Price(NewPlanUnitPrice value) => new(value); - /// - /// The id of the billable metric for the price. Only needed if the price is 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 static implicit operator Price(NewPlanTieredPrice value) => new(value); - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } + public static implicit operator Price(NewPlanBulkPrice value) => new(value); - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } + public static implicit operator Price(BulkWithFilters value) => new(value); - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } + public static implicit operator Price(NewPlanMatrixPrice 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 Price(NewPlanThresholdTotalAmountPrice 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 Price(NewPlanTieredPackagePrice 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 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(MatrixWithThresholdDiscounts value) => new(value); + + public static implicit operator Price(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value) => new(value); + + public static implicit operator Price(DailyCreditAllowance value) => new(value); + + public static implicit operator Price(MeteredAllowance value) => new(value); + + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + + public static implicit operator Price(Percent value) => new(value); + + public static implicit operator Price(EventOutput value) => new(value); /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public double? FixedPriceQuantity + public override void Validate() { - get + if (this.Value == null) { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + throw new OrbInvalidDataException("Data did not match any variant of Price"); } - init { this._rawData.Set("fixed_price_quantity", value); } + 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + return 0; } - /// - /// Within 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 override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + MatrixWithThresholdDiscounts _ => 14, + TieredWithProration _ => 15, + NewPlanUnitWithProrationPrice _ => 16, + NewPlanGroupedAllocationPrice _ => 17, + NewPlanBulkWithProrationPrice _ => 18, + NewPlanGroupedWithProratedMinimumPrice _ => 19, + NewPlanGroupedWithMeteredMinimumPrice _ => 20, + GroupedWithMinMaxThresholds _ => 21, + NewPlanMatrixWithDisplayNamePrice _ => 22, + NewPlanGroupedTieredPackagePrice _ => 23, + NewPlanMaxGroupTieredPackagePrice _ => 24, + NewPlanScalableMatrixWithUnitPricingPrice _ => 25, + NewPlanScalableMatrixWithTieredPricingPrice _ => 26, + NewPlanCumulativeGroupedBulkPrice _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + NewPlanMinimumCompositePrice _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -1, + }; } +} - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata +sealed class PriceConverter : JsonConverter +{ + public override Price? 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.GetNullableClass>("metadata"); + modelType = element.GetProperty("model_type").GetString(); } - init + catch { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + modelType = null; } - } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get + switch (modelType) { - 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 BulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFilters(global::Orb.Models.Beta.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class BulkWithFiltersFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFilters.FromRawUnchecked(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 + } -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFiltersConfig, - global::Orb.Models.Beta.BulkWithFiltersConfigFromRaw - >) -)] -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) - ); - } - } + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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) - ); - } - } + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } - - public BulkWithFiltersConfig( - global::Orb.Models.Beta.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + 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 + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class BulkWithFiltersConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -/// -/// 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 -{ - /// - /// 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); } - } + return new(element); + } + case "matrix_with_threshold_discounts": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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); } - } + 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 override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } + 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 Filter() { } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public Filter(global::Orb.Models.Beta.Filter filter) - : base(filter) { } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public Filter(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + 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 + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + 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 + } - /// - public static global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + 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 + } -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Filter.FromRawUnchecked(rawData); -} + 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 + } -/// -/// 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); } - } + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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); } - } + 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 override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + 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 Tier() { } + 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 Tier(global::Orb.Models.Beta.Tier tier) - : base(tier) { } + 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 Tier(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Tier(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "daily_credit_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class TierFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Tier.FromRawUnchecked(rawData); -} + return new(element); + } + case "percent": + { + 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(global::Orb.Models.Beta.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -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), - }; + return new(element); + } + default: + { + return new Price(element); + } + } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? 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 - ); + JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter(typeof(global::Orb.Models.Beta.ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFilters : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; + /// + /// 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); } + } - public JsonElement Json + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" ); } + init { this._rawData.Set("cadence", value); } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + /// + /// The pricing model type + /// + public JsonElement ModelType { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } } - public ConversionRateConfig(JsonElement element) + /// + /// The name of the price. + /// + public required string Name { - this._element = element; + 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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public string? BillableMetricID { - value = this.Value as SharedUnitConversionRateConfig; - 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.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// 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 TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool? BilledInAdvance { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public void Switch( - System::Action unit, - System::Action tiered - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - switch (this.Value) + get { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } + init { this._rawData.Set("billing_cycle_configuration", 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( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public T Match( - System::Func unit, - System::Func tiered - ) + public double? ConversionRate { - return this.Value switch + get { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public override void Validate() + public BulkWithFiltersConversionRateConfig? ConversionRateConfig { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" ); } - 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 override int GetHashCode() - { - return 0; + init { this._rawData.Set("conversion_rate_config", value); } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - 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.ConversionRateConfig(element); - } + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); } + init { this._rawData.Set("currency", value); } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProration, - global::Orb.Models.Beta.TieredWithProrationFromRaw - >) -)] -public sealed record class TieredWithProration : JsonModel -{ /// - /// The cadence to bill for this price on. + /// For dimensional price: specifies a price group and dimension values /// - public required ApiEnum Cadence + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("dimensional_price_configuration", value); } } /// - /// The id of the item the price will be associated with. + /// An alias for the price. /// - public required string ItemID + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The pricing model type + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public JsonElement ModelType + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("fixed_price_quantity", value); } } /// - /// The name of the price. + /// The property used to group this price on an invoice /// - public required string Name + public string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } /// - /// Configuration for tiered_with_proration pricing + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public required global::Orb.Models.Beta.TieredWithProrationConfig TieredWithProrationConfig + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// The ID of the license type to associate with this price. /// - public string? BillableMetricID + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNullableClass("license_type_id"); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("license_type_id", value); } } /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. + /// User-specified key/value pairs for the resource. Individual 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? BilledInAdvance + public IReadOnlyDictionary? Metadata { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); } - init { this._rawData.Set("billed_in_advance", value); } } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public string? ReferenceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + return this._rawData.GetNullableClass("reference_id"); } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.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.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); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + init { this._rawData.Set("reference_id", value); } } /// 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(); @@ -4885,222 +4928,226 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public TieredWithProration(global::Orb.Models.Beta.TieredWithProration tieredWithProration) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFilters(BulkWithFilters bulkWithFilters) + : base(bulkWithFilters) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public BulkWithFilters(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] - TieredWithProration(FrozenDictionary rawData) + BulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProration.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class TieredWithProrationCadenceConverter - : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFiltersConfig : JsonModel { - public override global::Orb.Models.Beta.TieredWithProrationCadence 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.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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "filters", + ImmutableArray.ToImmutableArray(value) + ); + } } -} -/// -/// 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 -{ /// - /// 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 - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + 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 TieredWithProrationConfig() { } + public BulkWithFiltersConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Beta.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) + : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + BulkWithFiltersConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class TieredWithProrationConfigFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfigTier, - global::Orb.Models.Beta.TieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Filter : JsonModel { /// - /// Inclusive tier starting value + /// Event property key to filter on /// - public required string TierLowerBound + public required string PropertyKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("property_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + 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 /// @@ -5114,53 +5161,129 @@ public required string UnitAmount 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.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public TieredWithProrationConfigTier() { } + public Tier() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) + : base(tier) { } +#pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public Tier(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + Tier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +/// +/// 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(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5177,7 +5300,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5186,7 +5309,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5195,7 +5318,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -5204,7 +5327,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 +5348,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 +5368,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 +5379,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5277,7 +5400,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of BulkWithFiltersConversionRateConfig" ); } } @@ -5286,7 +5409,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 +5420,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5313,16 +5436,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 BulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5341,18 +5464,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 BulkWithFiltersConversionRateConfig" ); } 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(BulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5360,13 +5481,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 BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5395,12 +5529,10 @@ JsonSerializerOptions 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 +5549,10 @@ JsonSerializerOptions 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 +5561,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.TieredWithProrationConversionRateConfig(element); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -5447,57 +5577,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +public sealed record class MatrixWithThresholdDiscounts : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for matrix_with_threshold_discounts pricing /// - public required string ItemID + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// @@ -5585,12 +5709,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 MatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5681,6 +5805,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5720,12 +5857,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { @@ -5743,37 +5880,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public MatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + MatrixWithThresholdDiscounts(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5781,20 +5920,19 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( + public MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence { Annual, SemiAnnual, @@ -5804,10 +5942,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence Read( + public override MatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5815,19 +5953,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" => MatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence value, + MatrixWithThresholdDiscountsCadence value, JsonSerializerOptions options ) { @@ -5835,13 +5973,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", + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5852,99 +5989,138 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for matrix_with_threshold_discounts pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfigFromRaw + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Unit price used for usage that does not match any defined matrix cell. /// - public required string GroupingKey + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("default_unit_amount"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("default_unit_amount", value); } } /// - /// The maximum amount to charge each group + /// First matrix dimension key. /// - public required string MaximumCharge + public required string FirstDimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("first_dimension"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("first_dimension", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// Per-cell unit prices. /// - public required string MinimumCharge + public required IReadOnlyList MatrixValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullStruct>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("minimum_charge", value); } } /// - /// The base price charged per group + /// Optional second matrix dimension key. /// - public required string PerUnitRate + public string? SecondDimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNullableClass("second_dimension"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("second_dimension", value); } } - /// - public override void Validate() + public IReadOnlyList? ThresholdDiscountGroups { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } - public GroupedWithMinMaxThresholdsConfig() { } + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + public MatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5952,19 +6128,205 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public MatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 + + public MatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixValueFromRaw : IFromRawJson +{ + /// + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public ThresholdDiscountGroup() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 + + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdDiscountGroupFromRaw : IFromRawJson +{ + /// + public ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5981,7 +6343,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5990,7 +6352,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5999,7 +6361,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) { this._element = element; } @@ -6008,7 +6370,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 +6391,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 +6411,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 +6422,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6081,7 +6443,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" ); } } @@ -6090,7 +6452,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 +6463,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6117,16 +6479,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 MatrixWithThresholdDiscountsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6145,18 +6507,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 MatrixWithThresholdDiscountsConversionRateConfig" ); } 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(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6164,13 +6524,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 MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6199,12 +6572,10 @@ JsonSerializerOptions 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 +6592,10 @@ JsonSerializerOptions 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 +6604,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new MatrixWithThresholdDiscountsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig value, + MatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6252,45 +6619,22 @@ 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 TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence - > 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 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); } } /// @@ -6332,6 +6676,21 @@ public required string 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. /// @@ -6391,12 +6750,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 TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6487,6 +6846,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6526,18 +6898,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + 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(); @@ -6549,37 +6921,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public TieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public TieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + TieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6587,20 +6961,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence { Annual, SemiAnnual, @@ -6610,10 +6982,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6621,19 +6992,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" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -6641,13 +7012,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", + 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)) ), @@ -6658,57 +7028,112 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.CumulativeGroupedAllocationConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class TieredWithProrationConfig : JsonModel { /// - /// The overall allocation across all groups + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string CumulativeAllocation + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("cumulative_allocation", value); } } - /// - /// The allocation per individual group - /// - public required string GroupAllocation + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + item.Validate(); } - init { this._rawData.Set("group_allocation", value); } } + 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 +{ /// - /// The event property used to group usage before applying allocations + /// Inclusive tier starting value /// - public required string GroupingKey + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Amount per unit /// public required string UnitAmount { @@ -6723,34 +7148,35 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.TierLowerBound; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public TieredWithProrationConfigTier() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier ) - : base(cumulativeGroupedAllocationConfig) { } + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + TieredWithProrationConfigTier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6758,19 +7184,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6787,7 +7210,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6796,7 +7219,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6805,7 +7228,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public TieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -6814,7 +7237,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 +7258,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 +7278,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 +7289,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6887,7 +7310,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } } @@ -6896,7 +7319,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 +7330,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6923,16 +7346,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 TieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6951,18 +7374,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 TieredWithProrationConversionRateConfig" ); } 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(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6970,13 +7391,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 TieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7005,12 +7439,10 @@ JsonSerializerOptions 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 +7459,10 @@ JsonSerializerOptions 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 +7471,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7059,52 +7487,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Minimum, - global::Orb.Models.Beta.MinimumFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class Minimum : JsonModel +public sealed record class GroupedWithMinMaxThresholds : 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 grouped_with_min_max_thresholds pricing /// - public required string ItemID + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.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); } } /// @@ -7192,12 +7619,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7288,6 +7715,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7327,9 +7767,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -7345,35 +7790,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public Minimum(global::Orb.Models.Beta.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Minimum FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7381,19 +7830,19 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Minimum FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Minimum.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -7403,9 +7852,10 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override MinimumCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7413,19 +7863,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" => 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, - MinimumCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -7433,12 +7883,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", + 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)) ), @@ -7449,101 +7899,119 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.MinimumConfig, - global::Orb.Models.Beta.MinimumConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The minimum amount to apply + /// The event property used to group before applying thresholds /// - public required string MinimumAmount + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The maximum amount to charge each group /// - public bool? Prorated + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init + init { this._rawData.Set("maximum_charge", value); } + } + + /// + /// The minimum amount to charge each group, regardless of usage + /// + public required string MinimumCharge + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_charge"); + } + init { this._rawData.Set("minimum_charge", value); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public MinimumConfig() { } + public GroupedWithMinMaxThresholdsConfig() { } - public MinimumConfig(global::Orb.Models.Beta.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.MinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7560,7 +8028,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7569,7 +8037,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7578,7 +8046,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -7587,7 +8055,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 +8076,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 +8096,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 +8107,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7660,7 +8128,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -7669,7 +8137,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 +8148,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7696,16 +8164,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 GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7724,16 +8192,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 GroupedWithMinMaxThresholdsConversionRateConfig" ); } 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(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7741,12 +8209,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 GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7775,12 +8257,10 @@ JsonSerializerOptions 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 +8277,10 @@ JsonSerializerOptions 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 +8289,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -7827,80 +8305,77 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Percent, - global::Orb.Models.Beta.PercentFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class Percent : JsonModel +public sealed record class CumulativeGroupedAllocation : 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); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required CumulativeGroupedAllocationConfig 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); } } /// - /// The pricing model type + /// The id of the item the price will be associated with. /// - public JsonElement ModelType + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The name of the price. + /// The pricing model type /// - public required string Name + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("model_type", value); } } /// - /// Configuration for percent pricing + /// The name of the price. /// - public required global::Orb.Models.Beta.PercentConfig PercentConfig + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("percent_config", value); } + init { this._rawData.Set("name", value); } } /// @@ -7962,12 +8437,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 CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8058,6 +8533,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -8097,13 +8585,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8115,35 +8608,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public Percent(global::Orb.Models.Beta.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Percent FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8151,19 +8648,19 @@ IReadOnlyDictionary rawData } } -class PercentFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Percent FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Percent.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -8173,9 +8670,10 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.PercentCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8183,19 +8681,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" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -8203,12 +8701,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", + 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)) ), @@ -8219,79 +8717,119 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.PercentConfig, - global::Orb.Models.Beta.PercentConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class PercentConfig : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The overall allocation across all groups /// - public required double Percent + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("percent", value); } + 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.Percent; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public PercentConfig() { } + public CumulativeGroupedAllocationConfig() { } - public PercentConfig(global::Orb.Models.Beta.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.PercentConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.PercentConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.PercentConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8308,7 +8846,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8317,7 +8855,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8326,7 +8864,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -8335,7 +8873,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 +8894,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 +8914,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 +8925,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8408,7 +8946,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -8417,7 +8955,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 +8966,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8444,16 +8982,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8472,16 +9010,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 CumulativeGroupedAllocationConversionRateConfig" ); } 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(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8489,13 +9027,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.PercentConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8524,12 +9075,10 @@ JsonSerializerOptions 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 +9095,10 @@ JsonSerializerOptions 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 +9107,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.PercentConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -8575,42 +9122,37 @@ 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 DailyCreditAllowance : 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 + /// Configuration for daily_credit_allowance pricing /// - public required global::Orb.Models.Beta.EventOutputConfig EventOutputConfig + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -8711,12 +9253,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 DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8807,6 +9349,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +9401,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("event_output") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -8869,35 +9424,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public EventOutput(global::Orb.Models.Beta.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutput FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8905,19 +9464,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutput FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutput.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -8927,9 +9486,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.EventOutputCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8937,19 +9496,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" => DailyCreditAllowanceCadence.Annual, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "one_time" => DailyCreditAllowanceCadence.OneTime, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -8957,12 +9516,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", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8973,110 +9532,239 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutputConfig, - global::Orb.Models.Beta.EventOutputConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class EventOutputConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string UnitRatingKey + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("daily_allowance", 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. + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public string? DefaultUnitRate + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("default_unit_amount"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("default_unit_amount", 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. + /// One or two event property values to evaluate matrix groups by /// - public string? GroupingKey + public required IReadOnlyList Dimensions { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public EventOutputConfig() { } + public DailyCreditAllowanceConfig() { } - public EventOutputConfig(global::Orb.Models.Beta.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() +class DailyCreditAllowanceConfigFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class DailyCreditAllowanceConfigMatrixValue : JsonModel +{ + /// + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. + /// + public required IReadOnlyList DimensionValues { - this.UnitRatingKey = unitRatingKey; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Credits charged per unit of usage matching the specified dimension_values + /// + 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.DimensionValues; + _ = this.UnitAmount; + } + + public DailyCreditAllowanceConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue + ) + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputConfigFromRaw : IFromRawJson +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutputConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9093,7 +9781,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9102,7 +9790,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9111,7 +9799,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -9120,7 +9808,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 +9829,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 +9849,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 +9860,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9193,7 +9881,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -9202,7 +9890,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 +9901,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9229,16 +9917,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9257,16 +9945,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9274,13 +9962,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.EventOutputConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9309,12 +10010,10 @@ JsonSerializerOptions 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 +10030,10 @@ JsonSerializerOptions 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 +10042,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.EventOutputConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9360,435 +10057,655 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : 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. + /// Configuration for metered_allowance pricing /// - public required string PriceID + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("metered_allowance_config", 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; - } - - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("model_type", value); } } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + /// + /// The name of the price. + /// + public required string Name { - this.PriceID = priceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", 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. + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public required ReplaceAdjustmentAdjustment Adjustment + public string? BillableMetricID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNullableClass("billable_metric_id"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("billable_metric_id", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. /// - public required string ReplacesAdjustmentID + public bool? BilledInAdvance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableStruct("billed_in_advance"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("billed_in_advance", value); } } /// - /// The phase to replace this adjustment from. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public long? PlanPhaseOrder + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - /// - public override void Validate() + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } -#pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", 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; + /// + /// An alias for 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 JsonElement Json + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + 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( - 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("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public bool? IsInvoiceLevel + /// + /// Within each 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.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount 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(NewMinimum value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + this.Cadence.Validate(); + _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + 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(NewMaximum value, JsonElement? element = null) + public MeteredAllowance() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public ReplaceAdjustmentAdjustment(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 + + public MeteredAllowance(IReadOnlyDictionary rawData) { - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - /// - /// Returns true and sets the 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) +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowance(FrozenDictionary rawData) { - value = this.Value as NewPercentageDiscount; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 static MeteredAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - value = this.Value as NewUsageDiscount; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class MeteredAllowanceFromRaw : IFromRawJson +{ + /// + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MeteredAllowanceCadenceConverter : JsonConverter +{ + public override MeteredAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MeteredAllowanceCadence.Annual, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "one_time" => MeteredAllowanceCadence.OneTime, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} +/// +/// Configuration for metered_allowance pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public required string AllowanceGroupingValue { - value = this.Value as NewAmountDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); + } + } + + /// + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + /// + public string? ConsumptionDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); + } + } + + /// + public override void Validate() + { + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; + } + + public MeteredAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 + + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowanceConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MeteredAllowanceConfigFromRaw : IFromRawJson +{ + /// + public MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig(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 +10716,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 MeteredAllowanceConversionRateConfig" ); } } @@ -9844,7 +10746,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,209 +10757,6356 @@ 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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => - new(value); + public static implicit operator MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of MeteredAllowanceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MeteredAllowanceConversionRateConfigConverter + : JsonConverter +{ + public override MeteredAllowanceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 MeteredAllowanceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceConversionRateConfig 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); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// 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; + 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 + ); + } +} + +/// +/// 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); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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; + 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(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); + } +} + +[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(JsonModelConverter< + ReplacePriceLicenseAllocationPrice, + ReplacePriceLicenseAllocationPriceFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPrice : 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 required ApiEnum ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + 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.ModelType.Validate(); + _ = 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 ReplacePriceLicenseAllocationPrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPrice replacePriceLicenseAllocationPrice + ) + : base(replacePriceLicenseAllocationPrice) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPrice(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceFromRaw : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPrice.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceLicenseAllocation, + ReplacePriceLicenseAllocationPriceLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceLicenseAllocation( + ReplacePriceLicenseAllocationPriceLicenseAllocation replacePriceLicenseAllocationPriceLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// The pricing model type +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceModelTypeConverter))] +public enum ReplacePriceLicenseAllocationPriceModelType +{ + Unit, +} + +sealed class ReplacePriceLicenseAllocationPriceModelTypeConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceModelType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unit" => ReplacePriceLicenseAllocationPriceModelType.Unit, + _ => (ReplacePriceLicenseAllocationPriceModelType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceModelType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceModelType.Unit => "unit", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 ReplacePriceLicenseAllocationPriceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceConversionRateConfig 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (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( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePriceMeteredAllowance 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.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `ReplacePricePriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out ReplacePricePriceMatrixWithThresholdDiscounts? value + ) + { + value = this.Value as ReplacePricePriceMatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the 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.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out ReplacePricePriceDailyCreditAllowance? value + ) + { + value = this.Value as ReplacePricePriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] out ReplacePricePriceMeteredAllowance? value + ) + { + value = this.Value as ReplacePricePriceMeteredAllowance; + return value != null; + } + + /// + /// Returns true and sets the 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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + 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 ReplacePricePriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(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 ReplacePricePriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case ReplacePricePriceMeteredAllowance value: + meteredAllowance(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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Func meteredAllowance, + 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), + ReplacePricePriceMatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts( + 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 + ), + ReplacePricePriceDailyCreditAllowance value => dailyCreditAllowance(value), + ReplacePricePriceMeteredAllowance value => meteredAllowance(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( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceMeteredAllowance 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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, + ReplacePricePriceMatrixWithThresholdDiscounts _ => 14, + ReplacePricePriceTieredWithProration _ => 15, + NewPlanUnitWithProrationPrice _ => 16, + NewPlanGroupedAllocationPrice _ => 17, + NewPlanBulkWithProrationPrice _ => 18, + NewPlanGroupedWithProratedMinimumPrice _ => 19, + NewPlanGroupedWithMeteredMinimumPrice _ => 20, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 21, + NewPlanMatrixWithDisplayNamePrice _ => 22, + NewPlanGroupedTieredPackagePrice _ => 23, + NewPlanMaxGroupTieredPackagePrice _ => 24, + NewPlanScalableMatrixWithUnitPricingPrice _ => 25, + NewPlanScalableMatrixWithTieredPricingPrice _ => 26, + NewPlanCumulativeGroupedBulkPrice _ => 27, + ReplacePricePriceCumulativeGroupedAllocation _ => 28, + ReplacePricePriceDailyCreditAllowance _ => 29, + ReplacePricePriceMeteredAllowance _ => 30, + NewPlanMinimumCompositePrice _ => 31, + ReplacePricePricePercent _ => 32, + ReplacePricePriceEventOutput _ => 33, + _ => -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 "matrix_with_threshold_discounts": + { + 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 + } - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); + 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 + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + 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 + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + 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 + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when 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() - ); - } + 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 virtual bool Equals(ReplaceAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + 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 override int GetHashCode() - { - return 0; - } + 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 override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + 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 + } -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; - } + 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 (adjustmentType) - { - case "percentage_discount": + return new(element); + } + case "daily_credit_allowance": { 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 "usage_discount": + case "metered_allowance": { 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 "amount_discount": + 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 "minimum": + 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 "maximum": + 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 } @@ -10066,2846 +17115,2107 @@ JsonSerializerOptions options } default: { - return new ReplaceAdjustmentAdjustment(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + ReplacePricePrice? 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 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.PlanPhaseOrder; - this.Price?.Validate(); - } - - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - 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); -} - -/// -/// 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, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); - } + ) + { + JsonSerializer.Serialize(writer, value?.Json, options); } +} - public string Name +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig { 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.GetNotNullClass( + "bulk_with_filters_config" ); } + init { this._rawData.Set("bulk_with_filters_config", value); } } - public string? BillableMetricID + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { 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.GetNotNullClass< + ApiEnum + >("cadence"); } + init { this._rawData.Set("cadence", value); } } - public bool? BilledInAdvance + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { 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.GetNotNullClass("item_id"); } + init { this._rawData.Set("item_id", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// The pricing model type + /// + public JsonElement ModelType { 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.GetNotNullStruct("model_type"); } + init { this._rawData.Set("model_type", value); } } - public double? ConversionRate + /// + /// The name of the price. + /// + public required string Name { 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.GetNotNullClass("name"); } + init { this._rawData.Set("name", value); } } - 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, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); + /// + /// The id of the billable metric for the price. Only needed if the price is 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 NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { 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.GetNullableStruct("billed_in_advance"); } + init { this._rawData.Set("billed_in_advance", value); } } - public string? ExternalPriceID + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { 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( + "billing_cycle_configuration" ); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - public double? FixedPriceQuantity + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { 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.GetNullableStruct("conversion_rate"); } + init { this._rawData.Set("conversion_rate", value); } } - public string? InvoiceGroupingKey + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { 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( + "conversion_rate_config" ); } + init { this._rawData.Set("conversion_rate_config", value); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// 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.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("currency"); } + init { this._rawData.Set("currency", value); } } - public string? ReferenceID + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get - { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + /// + /// An alias for the price. + /// + public string? ExternalPriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public ReplacePricePrice(NewPlanTieredPackagePrice 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 ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + 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 ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public ReplacePricePriceBulkWithFilters() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - { - this.Value = value; - this._element = element; - } + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } } - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } } - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) - { - this.Value = value; - this._element = element; - } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) +/// +/// 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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } } - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + /// Event property value to match + /// + public required string PropertyValue { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } } - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.PropertyKey; + _ = this.PropertyValue; } - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - { - this.Value = value; - this._element = element; - } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} - public ReplacePricePrice(JsonElement element) +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +{ + /// + /// Amount per unit + /// + public required string UnitAmount { - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_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.TryPickNewPlanUnit(out var value)) { - /// // `value` is of type `NewPlanUnitPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The lower bound for this tier /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public string? TierLowerBound { - value = this.Value as NewPlanUnitPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + /// + public override void Validate() { - value = this.Value as NewPlanTieredPrice; - return value != null; + _ = this.UnitAmount; + _ = this.TierLowerBound; } - /// - /// Returns true and sets the 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) + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) { - value = this.Value as NewPlanBulkPrice; - return value != null; + this._rawData = new(rawData); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData ) { - value = this.Value as ReplacePricePriceBulkWithFilters; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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) + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - value = this.Value as NewPlanPackagePrice; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() { - value = this.Value as NewPlanMatrixPrice; - return value != null; + this.UnitAmount = unitAmount; } +} - /// - /// Returns true and sets the 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 +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; + 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), + }; } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; + 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 + ); } +} - /// - /// Returns true and sets the 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 - ) +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null ) { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + this.Value = value; + this._element = element; + } + + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + { + this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// 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.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewPlanPackageWithAllocationPrice; + value = 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.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewPlanUnitWithPercentPrice; + 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.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + public void Switch( + System::Action unit, + System::Action tiered ) { - value = this.Value as NewPlanMatrixWithAllocationPrice; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as ReplacePricePriceTieredWithProration; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; } + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanUnitWithProrationPrice; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscounts, + ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscounts : 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.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The cadence to bill for this price on. /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public required ApiEnum Cadence { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("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.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value - ) + public required string ItemID { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Configuration for matrix_with_threshold_discounts pricing /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public required ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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); - /// } - /// - /// + /// The pricing model type /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public JsonElement ModelType { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - 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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The name of the price. /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public required string Name { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanGroupedTieredPackagePrice; - 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// 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 TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public double? ConversionRate { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - 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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// + /// For dimensional price: specifies a price group and dimension values /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as ReplacePricePriceMinimum; - 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// An alias for the price. /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewPlanMinimumCompositePrice; - 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.TryPickPercent(out var value)) { - /// // `value` is of type `ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) + public double? FixedPriceQuantity { - value = this.Value as ReplacePricePricePercent; - 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// + /// The property used to group this price on an invoice /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) + public string? InvoiceGroupingKey { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_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) => {...} - /// ); - /// - /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - 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 NewBillingCycleConfiguration? InvoicingCycleConfiguration { - 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.GetNullableClass( + "invoicing_cycle_configuration" + ); } + init { this._rawData.Set("invoicing_cycle_configuration", 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) => {...} - /// ); - /// - /// + /// The ID of the license type to associate with this price. /// - 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 string? LicenseTypeID { - return this.Value switch + get { - 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" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public static implicit operator ReplacePricePrice(NewPlanUnitPrice 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(NewPlanTieredPrice 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(NewPlanBulkPrice value) => new(value); + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => - new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscounts( + ReplacePricePriceMatrixWithThresholdDiscounts replacePricePriceMatrixWithThresholdDiscounts + ) + : base(replacePricePriceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); - public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => - new(value); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => - new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => - new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceMatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => - new(value); +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter))] +public enum ReplacePricePriceMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => - new(value); +sealed class ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom, + _ => (ReplacePricePriceMatrixWithThresholdDiscountsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual => "annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly => "monthly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime => "one_time", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } - public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => - new(value); + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } - public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => - new(value); + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } - public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => - new(value); + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } - public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => - new(value); + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } - public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => - new(value); + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base(replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => - new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => - new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } - public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => - new(value); + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.UnitAmount; + _ = this.SecondDimensionValue; + } - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } - public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances 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 static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newPlanPackage) => newPlanPackage.Validate(), - (newPlanMatrix) => newPlanMatrix.Validate(), - (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), - (newPlanTieredPackage) => newPlanTieredPackage.Validate(), - (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), - (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), - (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), - (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), - (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), - (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} - public virtual bool Equals(ReplacePricePrice? other) +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } } - public override int GetHashCode() + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage { - return 0; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try + get { - modelType = element.GetProperty("model_type").GetString(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); } - catch + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get { - modelType = null; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); } + init { this._rawData.Set("threshold_amount", value); } + } - switch (modelType) + public string? Description + { + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (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 - } + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", 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 - } + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - 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 - } +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} - 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 - } +[JsonConverter(typeof(ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + JsonElement? _element = null; - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `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 "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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `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_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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } - 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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - 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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - 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 - } + public virtual bool Equals( + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - 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 - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - return new(element); - } - case "percent": +sealed class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + 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 "event_output": + 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 } @@ -12914,54 +19224,41 @@ JsonSerializerOptions options } default: { - return new ReplacePricePrice(element); + return new ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePrice? value, + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : 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); } @@ -13006,6 +19303,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. /// @@ -13065,12 +19377,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -13161,6 +19473,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19524,19 @@ 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") + 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(); @@ -13223,37 +19548,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceBulkWithFilters() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceBulkWithFilters) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13261,172 +19590,127 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this._rawData = new(rawData); + 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), + }; } -#pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(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 + ); } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} - /// -/// Configuration for a single property filter +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// Event property key to filter on + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string PropertyKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData ) { @@ -13435,7 +19719,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -13443,76 +19727,89 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel { /// - /// Amount per unit + /// Inclusive tier starting value /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The lower bound for this tier + /// Amount per unit /// - public string? TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.UnitAmount; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -13521,7 +19818,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -13529,93 +19826,27 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", - ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", - ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", - ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", - ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", - ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -13632,7 +19863,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -13641,7 +19872,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -13650,7 +19881,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -13659,7 +19890,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig(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. /// /// /// @@ -13680,7 +19911,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. /// /// /// @@ -13700,7 +19931,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. /// /// @@ -13711,8 +19942,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -13732,7 +19963,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -13741,7 +19972,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. /// /// @@ -13752,8 +19983,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -13768,16 +19999,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -13796,16 +20027,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -13813,13 +20044,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 ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -13848,12 +20092,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13870,12 +20112,10 @@ JsonSerializerOptions 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,14 +20124,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -13901,27 +20141,42 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : 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 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. /// @@ -13961,21 +20216,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 +20275,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14131,6 +20371,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -14170,18 +20423,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -14193,37 +20446,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceGroupedWithMinMaxThresholds( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14231,20 +20490,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] -public enum ReplacePricePriceTieredWithProrationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -14254,10 +20513,10 @@ public enum ReplacePricePriceTieredWithProrationCadence Custom, } -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14265,19 +20524,19 @@ 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), + "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, - ReplacePricePriceTieredWithProrationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -14285,12 +20544,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceTieredWithProrationCadence.Annual => "annual", - ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", - ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", - ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", - ReplacePricePriceTieredWithProrationCadence.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)) ), @@ -14301,150 +20560,89 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel -{ - /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig - ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Inclusive tier starting value + /// The event property used to group before applying thresholds /// - public required string TierLowerBound + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// Amount per unit + /// The maximum amount to charge each group /// - public required string UnitAmount + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -14453,7 +20651,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -14461,8 +20659,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14470,18 +20668,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14498,7 +20698,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14507,7 +20707,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14516,7 +20716,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -14525,7 +20725,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 +20746,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 +20766,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 +20777,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14598,7 +20798,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -14607,7 +20807,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 +20818,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14634,16 +20834,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14662,16 +20862,18 @@ 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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } 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( + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14679,13 +20881,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14714,12 +20929,10 @@ JsonSerializerOptions 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 +20949,10 @@ JsonSerializerOptions 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 +20961,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -14767,40 +20980,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholds, - ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : 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< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// Configuration for cumulative_grouped_allocation pricing /// - public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -14901,12 +21114,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14997,6 +21210,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +21262,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -15059,39 +21285,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( + public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15099,20 +21329,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -15122,10 +21352,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15133,19 +21363,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" => 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, - ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -15153,12 +21383,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", + 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)) ), @@ -15169,86 +21399,89 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -15257,7 +21490,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -15265,8 +21498,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15274,20 +21507,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15304,7 +21537,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15313,7 +21546,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15322,7 +21555,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15331,7 +21564,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 +21585,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 +21605,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 +21616,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15404,7 +21637,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -15413,7 +21646,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 +21657,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15440,16 +21673,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15468,18 +21701,18 @@ 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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? 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() { @@ -15487,13 +21720,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15522,12 +21768,10 @@ JsonSerializerOptions 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 +21788,10 @@ JsonSerializerOptions 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,7 +21800,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -15567,7 +21809,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15577,40 +21819,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceDailyCreditAllowance, + ReplacePricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceDailyCreditAllowance : 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 daily_credit_allowance pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -15711,12 +21953,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15807,6 +22049,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22101,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -15869,39 +22124,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public ReplacePricePriceCumulativeGroupedAllocation( - ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowance( + ReplacePricePriceDailyCreditAllowance replacePricePriceDailyCreditAllowance ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceDailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceDailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15909,20 +22166,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceDailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceCadenceConverter))] +public enum ReplacePricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -15932,10 +22189,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15943,94 +22200,225 @@ 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" => ReplacePricePriceDailyCreditAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceDailyCreditAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceDailyCreditAllowanceCadence.OneTime, + "custom" => ReplacePricePriceDailyCreditAllowanceCadence.Custom, + _ => (ReplacePricePriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceDailyCreditAllowanceCadence.Annual => "annual", + ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceDailyCreditAllowanceCadence.Monthly => "monthly", + ReplacePricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceDailyCreditAllowanceCadence.OneTime => "one_time", + ReplacePricePriceDailyCreditAllowanceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + /// -/// Configuration for cumulative_grouped_allocation pricing +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -16045,20 +22433,21 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -16067,7 +22456,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -16075,8 +22464,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16084,20 +22473,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16114,7 +22503,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16123,7 +22512,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16132,7 +22521,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16141,7 +22530,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 +22551,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 +22571,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 +22582,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16214,7 +22603,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -16223,7 +22612,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 +22623,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16250,16 +22639,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16278,18 +22667,16 @@ 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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16297,13 +22684,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16332,12 +22732,10 @@ JsonSerializerOptions 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 +22752,10 @@ JsonSerializerOptions 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,16 +22764,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( - element - ); + return new ReplacePricePriceDailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -16386,21 +22780,24 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceMeteredAllowance, + ReplacePricePriceMeteredAllowanceFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceMeteredAllowance : 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); } } @@ -16419,18 +22816,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -16518,12 +22915,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16614,6 +23011,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -16654,8 +23064,13 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -16671,35 +23086,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowance( + ReplacePricePriceMeteredAllowance replacePricePriceMeteredAllowance + ) + : base(replacePricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16707,19 +23128,19 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceMeteredAllowanceFromRaw : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceCadenceConverter))] +public enum ReplacePricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -16729,10 +23150,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16740,19 +23161,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" => ReplacePricePriceMeteredAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceMeteredAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceMeteredAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceMeteredAllowanceCadence.OneTime, + "custom" => ReplacePricePriceMeteredAllowanceCadence.Custom, + _ => (ReplacePricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -16760,12 +23181,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", + ReplacePricePriceMeteredAllowanceCadence.Annual => "annual", + ReplacePricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMeteredAllowanceCadence.Monthly => "monthly", + ReplacePricePriceMeteredAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceMeteredAllowanceCadence.OneTime => "one_time", + ReplacePricePriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16776,38 +23197,103 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceMinimumMinimumConfig, - ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig, + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -16816,64 +23302,68 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig replacePricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceMeteredAllowanceMeteredAllowanceConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16890,7 +23380,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16899,7 +23389,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16908,7 +23398,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16917,7 +23407,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 +23428,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 +23448,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 +23459,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16990,7 +23480,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -16999,7 +23489,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 +23500,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17026,16 +23516,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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17054,16 +23544,16 @@ 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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } 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(ReplacePricePriceMeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17071,13 +23561,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 ReplacePricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17106,12 +23609,10 @@ JsonSerializerOptions 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 +23629,10 @@ JsonSerializerOptions 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 +23641,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceMeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -17386,6 +23885,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +23955,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17452,8 +23965,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 +24095,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 +24186,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 +24207,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 +24227,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 +24238,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17749,7 +24268,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 +24279,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17810,10 +24329,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 +24340,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +24388,10 @@ JsonSerializerOptions 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 +24408,10 @@ JsonSerializerOptions 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 +24664,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +24739,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18207,8 +24749,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 +24910,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 +25003,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 +25024,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 +25044,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 +25055,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18537,7 +25085,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 +25096,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18598,10 +25146,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 +25157,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +25205,10 @@ JsonSerializerOptions 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 +25225,10 @@ JsonSerializerOptions 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..6b9342006 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,4013 +949,3951 @@ 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(JsonModelConverter))] +public sealed record class LicenseAllocationPrice : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("cadence"); } + init { this._rawData.Set("cadence", value); } } - public string ItemID + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { get { - return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newPlanPackage: (x) => x.ItemID, - newPlanMatrix: (x) => x.ItemID, - newPlanThresholdTotalAmount: (x) => x.ItemID, - newPlanTieredPackage: (x) => x.ItemID, - newPlanTieredWithMinimum: (x) => x.ItemID, - newPlanGroupedTiered: (x) => x.ItemID, - newPlanTieredPackageWithMinimum: (x) => x.ItemID, - newPlanPackageWithAllocation: (x) => x.ItemID, - newPlanUnitWithPercent: (x) => x.ItemID, - newPlanMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newPlanUnitWithProration: (x) => x.ItemID, - newPlanGroupedAllocation: (x) => x.ItemID, - newPlanBulkWithProration: (x) => x.ItemID, - newPlanGroupedWithProratedMinimum: (x) => x.ItemID, - newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newPlanMatrixWithDisplayName: (x) => x.ItemID, - newPlanGroupedTieredPackage: (x) => x.ItemID, - newPlanMaxGroupTieredPackage: (x) => x.ItemID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, - newPlanCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); } + init { this._rawData.Set("item_id", value); } } - public string Name + /// + /// License allocations to associate with this price. Each entry defines 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 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.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) ); } } - public string? BillableMetricID + /// + /// The pricing model type + /// + public required ApiEnum ModelType { 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.GetNotNullClass>("model_type"); } + init { this._rawData.Set("model_type", value); } } - public bool? BilledInAdvance + /// + /// The name of the price. + /// + public required string Name { 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.GetNotNullClass("name"); } + init { this._rawData.Set("name", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Configuration for unit pricing + /// + public required UnitConfig UnitConfig { 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.GetNotNullClass("unit_config"); } + init { this._rawData.Set("unit_config", value); } } - public double? ConversionRate + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { 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("billable_metric_id"); } + init { this._rawData.Set("billable_metric_id", value); } } - public string? Currency + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { 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.GetNullableStruct("billed_in_advance"); } + init { this._rawData.Set("billed_in_advance", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { 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( + "billing_cycle_configuration" ); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - public string? ExternalPriceID + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { 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.GetNullableStruct("conversion_rate"); } + init { this._rawData.Set("conversion_rate", value); } } - public double? FixedPriceQuantity + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ConversionRateConfig? ConversionRateConfig { 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("conversion_rate_config"); } + init { this._rawData.Set("conversion_rate_config", value); } } - public string? InvoiceGroupingKey + /// + /// 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.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("currency"); } + init { this._rawData.Set("currency", value); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { 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( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public string? ReferenceID + /// + /// An alias for the price. + /// + public string? ExternalPriceID { get { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public Price(NewPlanUnitPrice value, JsonElement? element = null) + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } - public Price(NewPlanTieredPrice value, JsonElement? element = null) + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } - public Price(NewPlanBulkPrice value, JsonElement? element = null) + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public Price( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value, - JsonElement? element = null - ) + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public Price(NewPlanPackagePrice value, JsonElement? element = null) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public Price(NewPlanMatrixPrice 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 Price(NewPlanThresholdTotalAmountPrice 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(); + } + this.ModelType.Validate(); + _ = 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 Price(NewPlanTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public LicenseAllocationPrice() { } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocationPrice(LicenseAllocationPrice licenseAllocationPrice) + : base(licenseAllocationPrice) { } +#pragma warning restore CS8618 - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocationPrice(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + /// + public static LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class LicenseAllocationPriceFromRaw : IFromRawJson +{ + /// + public LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseAllocationPrice.FromRawUnchecked(rawData); +} - public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public Price( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value, - JsonElement? element = null +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), + }; } - public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : 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 Price(NewPlanBulkWithProrationPrice 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 Price(NewPlanGroupedWithProratedMinimumPrice 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 Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public LicenseAllocation() { } - public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 - public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocation(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class LicenseAllocationFromRaw : IFromRawJson +{ + /// + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); +} - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +/// +/// The pricing model type +/// +[JsonConverter(typeof(ModelTypeConverter))] +public enum ModelType +{ + Unit, +} - public Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value, - JsonElement? element = null +sealed class ModelTypeConverter : JsonConverter +{ + public override ModelType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unit" => ModelType.Unit, + _ => (ModelType)(-1), + }; } - public Price(global::Orb.Models.Beta.ExternalPlanID.Minimum value, JsonElement? element = null) + public override void Write( + Utf8JsonWriter writer, + ModelType value, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + ModelType.Unit => "unit", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : 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 Price(global::Orb.Models.Beta.ExternalPlanID.Percent value, JsonElement? element = null) + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.EventOutput value, - JsonElement? element = null - ) + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(JsonElement 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 . + /// 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 ConversionRateConfig" + ); + } } /// - /// 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.BulkWithFilters` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) - { - value = this.Value as NewPlanPackagePrice; - return value != null; + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ConversionRateConfig" + ), + }; } - /// - /// Returns true and sets the 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; - } + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); + + public static implicit operator ConversionRateConfig(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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public override void Validate() { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ConversionRateConfig" + ); + } + 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.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = this.Value as NewPlanTieredPackagePrice; - 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.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = this.Value as NewPlanTieredWithMinimumPrice; - 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.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value +sealed class ConversionRateConfigConverter : JsonConverter +{ + public override ConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanGroupedTieredPrice; - 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 ConversionRateConfig(element); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) +/// +/// 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 { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 - ) + public string ItemID { - value = this.Value as NewPlanUnitWithPercentPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ItemID, + newPlanTiered: (x) => x.ItemID, + newPlanBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newPlanPackage: (x) => x.ItemID, + newPlanMatrix: (x) => x.ItemID, + newPlanThresholdTotalAmount: (x) => x.ItemID, + newPlanTieredPackage: (x) => x.ItemID, + newPlanTieredWithMinimum: (x) => x.ItemID, + newPlanGroupedTiered: (x) => x.ItemID, + newPlanTieredPackageWithMinimum: (x) => x.ItemID, + newPlanPackageWithAllocation: (x) => x.ItemID, + newPlanUnitWithPercent: (x) => x.ItemID, + newPlanMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value - ) + public string Name { - value = this.Value as NewPlanMatrixWithAllocationPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.TieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.TieredWithProration? value - ) + public string? BillableMetricID { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.TieredWithProration; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - 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; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public double? ConversionRate { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newPlanMinimumComposite: (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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds? value - ) + public string? Currency { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newPlanMinimumComposite: (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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public string? ExternalPriceID { - 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; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoicingCycleConfiguration, + newPlanTiered: (x) => x.InvoicingCycleConfiguration, + newPlanBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newPlanPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMatrix: (x) => x.InvoicingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation? value - ) + public string? LicenseTypeID { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } } - /// - /// Returns true and sets the 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 - ) + public string? ReferenceID { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Minimum; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (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(BulkWithFilters 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(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(DailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(MeteredAllowance 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(Percent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(EventOutput 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` + /// if (instance.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - value = this.Value as NewPlanMinimumCompositePrice; + 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 . + /// 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` + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.Percent? value - ) + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Percent; + 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 . + /// 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` + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.EventOutput? value - ) + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.EventOutput; + value = this.Value as NewPlanBulkPrice; return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// Consider using or if you need to handle every variant. /// /// /// - /// instance.Switch( - /// (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) => {...} - /// ); + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `BulkWithFilters` + /// Console.WriteLine(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 - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - switch (this.Value) - { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters 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.TieredWithProration 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.GroupedWithMinMaxThresholds 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.CumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.Minimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.Percent value: - percent(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.EventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException("Data did not match any variant of Price"); - } + value = this.Value as BulkWithFilters; + return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// + /// + /// if (instance.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. /// /// /// - /// 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) => {...} - /// ); + /// if (instance.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(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 - ) + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) { - 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 - ), - 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"), - }; + value = this.Value as NewPlanMatrixPrice; + return value != null; } - 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 global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.Minimum value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMinimumCompositePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.Percent value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.EventOutput value - ) => new(value); + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance does not pass validation. - /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackage(out var value)) { + /// // `value` is of type `NewPlanTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public override void Validate() + public bool TryPickNewPlanTieredPackage( + [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + ) { - 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); + value = this.Value as NewPlanTieredPackagePrice; + return value != null; } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.Price? other) + /// + /// Returns true and sets the 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 + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + value = this.Value as NewPlanTieredWithMinimumPrice; + return value != null; } - public override int GetHashCode() + /// + /// Returns true and sets the 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 + ) { - return 0; + value = this.Value as NewPlanGroupedTieredPrice; + return value != null; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } -sealed class PriceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.Price? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } + value = this.Value as NewPlanPackageWithAllocationPrice; + return value != null; + } - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.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.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; + } - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value + ) + { + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `TieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + { + value = this.Value as TieredWithProration; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `GroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value + ) + { + value = this.Value as GroupedWithMinMaxThresholds; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + ) + { + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + return value != null; + } - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value + ) + { + value = this.Value as NewPlanCumulativeGroupedBulkPrice; + return value != null; + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `CumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out CumulativeGroupedAllocation? value + ) + { + value = this.Value as CumulativeGroupedAllocation; + return value != null; + } - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; + return value != null; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) + { + value = this.Value as MeteredAllowance; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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.Price(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Price? value, - JsonSerializerOptions options - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `Percent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - JsonSerializer.Serialize(writer, value?.Json, options); + value = this.Value as Percent; + return value != null; } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersFromRaw - >) -)] -public sealed record class BulkWithFilters : JsonModel -{ /// - /// Configuration for bulk_with_filters pricing + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `EventOutput` + /// Console.WriteLine(value); + /// } + /// + /// /// - public required global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig BulkWithFiltersConfig + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } + value = this.Value as EventOutput; + return value != null; } /// - /// The cadence to bill for this price on. + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the 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) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// /// - public required ApiEnum Cadence + 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + System::Action newPlanMinimumComposite, + System::Action percent, + System::Action eventOutput + ) { - get + switch (this.Value) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case BulkWithFilters 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 MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; + case TieredWithProration 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 GroupedWithMinMaxThresholds 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 CumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case Percent value: + percent(value); + break; + case EventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of Price"); } - init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was 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) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} + /// ); + /// + /// /// - public required string ItemID + 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Func meteredAllowance, + System::Func newPlanMinimumComposite, + System::Func percent, + System::Func eventOutput + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + BulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), + TieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), + }; } - /// - /// 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 static implicit operator Price(NewPlanUnitPrice value) => new(value); - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } + public static implicit operator Price(NewPlanTieredPrice value) => new(value); - /// - /// The id of the billable metric for the price. Only needed if the price is 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 static implicit operator Price(NewPlanBulkPrice value) => new(value); - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } + public static implicit operator Price(BulkWithFilters value) => new(value); - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } + public static implicit operator Price(NewPlanThresholdTotalAmountPrice 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 Price(NewPlanTieredPackagePrice 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 Price(NewPlanTieredWithMinimumPrice 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 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(MatrixWithThresholdDiscounts value) => new(value); + + public static implicit operator Price(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value) => new(value); + + public static implicit operator Price(DailyCreditAllowance value) => new(value); + + public static implicit operator Price(MeteredAllowance value) => new(value); + + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); + + public static implicit operator Price(Percent value) => new(value); + + public static implicit operator Price(EventOutput value) => new(value); /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public double? FixedPriceQuantity + public override void Validate() { - get + if (this.Value == null) { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + throw new OrbInvalidDataException("Data did not match any variant of Price"); } - init { this._rawData.Set("fixed_price_quantity", value); } + 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + return 0; } - /// - /// Within 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 override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + MatrixWithThresholdDiscounts _ => 14, + TieredWithProration _ => 15, + NewPlanUnitWithProrationPrice _ => 16, + NewPlanGroupedAllocationPrice _ => 17, + NewPlanBulkWithProrationPrice _ => 18, + NewPlanGroupedWithProratedMinimumPrice _ => 19, + NewPlanGroupedWithMeteredMinimumPrice _ => 20, + GroupedWithMinMaxThresholds _ => 21, + NewPlanMatrixWithDisplayNamePrice _ => 22, + NewPlanGroupedTieredPackagePrice _ => 23, + NewPlanMaxGroupTieredPackagePrice _ => 24, + NewPlanScalableMatrixWithUnitPricingPrice _ => 25, + NewPlanScalableMatrixWithTieredPricingPrice _ => 26, + NewPlanCumulativeGroupedBulkPrice _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + NewPlanMinimumCompositePrice _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -1, + }; } +} - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata +sealed class PriceConverter : JsonConverter +{ + public override Price? 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.GetNullableClass>("metadata"); + modelType = element.GetProperty("model_type").GetString(); } - init + catch { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + modelType = null; } - } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get + switch (modelType) { - 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 BulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFilters(global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class BulkWithFiltersFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters.FromRawUnchecked(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 + } -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfigFromRaw - >) -)] -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< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set>( - "filters", - ImmutableArray.ToImmutableArray(value) - ); - } - } + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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) - ); - } - } + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } - - public BulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + 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 + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class BulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -/// -/// 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 -{ - /// - /// 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); } - } + return new(element); + } + case "matrix_with_threshold_discounts": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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); } - } + 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 override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } + 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 Filter() { } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public Filter(global::Orb.Models.Beta.ExternalPlanID.Filter filter) - : base(filter) { } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public Filter(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + 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 + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + 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 + } - /// - public static global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + 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 + } -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Filter.FromRawUnchecked(rawData); -} + 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 + } -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Tier, - global::Orb.Models.Beta.ExternalPlanID.TierFromRaw - >) -)] -public sealed record class Tier : JsonModel -{ - /// - /// Amount per unit - /// - public required string UnitAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); - } - init { this._rawData.Set("unit_amount", value); } - } + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// 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); } - } + 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 override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + 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 Tier() { } + 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 Tier(global::Orb.Models.Beta.ExternalPlanID.Tier tier) - : base(tier) { } + 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 Tier(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Tier(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "daily_credit_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class TierFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Tier.FromRawUnchecked(rawData); -} + return new(element); + } + case "percent": + { + 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(global::Orb.Models.Beta.ExternalPlanID.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -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), - }; + return new(element); + } + default: + { + return new Price(element); + } + } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? 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 - ); + JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFilters : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; + /// + /// 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); } + } - public JsonElement Json + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" ); } + init { this._rawData.Set("cadence", value); } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + /// + /// The pricing model type + /// + public JsonElement ModelType { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } } - public ConversionRateConfig(JsonElement element) + /// + /// The name of the price. + /// + public required string Name { - this._element = element; + 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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public string? BillableMetricID { - value = this.Value as SharedUnitConversionRateConfig; - 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.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// 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 TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool? BilledInAdvance { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public void Switch( - System::Action unit, - System::Action tiered - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - switch (this.Value) + get { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } + init { this._rawData.Set("billing_cycle_configuration", 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( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public T Match( - System::Func unit, - System::Func tiered - ) + public double? ConversionRate { - return this.Value switch + get { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public override void Validate() + public BulkWithFiltersConversionRateConfig? ConversionRateConfig { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" ); } - 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 override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); + init { this._rawData.Set("conversion_rate_config", value); } } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationFromRaw - >) -)] -public sealed record class TieredWithProration : JsonModel -{ /// - /// The cadence to bill for this price on. + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence - > Cadence + public string? Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNullableClass("currency"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("currency", value); } } /// - /// The id of the item the price will be associated with. + /// For dimensional price: specifies a price group and dimension values /// - public required string ItemID + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("dimensional_price_configuration", value); } } /// - /// The pricing model type + /// An alias for the price. /// - public JsonElement ModelType + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The name of the price. + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public required string Name + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("fixed_price_quantity", value); } } /// - /// Configuration for tiered_with_proration pricing + /// The property used to group this price on an invoice /// - public required global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig TieredWithProrationConfig + public string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public string? BillableMetricID + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. + /// The ID of the license type to associate with this price. /// - public bool? BilledInAdvance + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableClass("license_type_id"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("license_type_id", value); } } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public IReadOnlyDictionary? Metadata { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } - init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The per unit conversion rate of the price currency to the invoicing currency. + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.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.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); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID + public string? ReferenceID { get { @@ -4923,19 +4906,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(); @@ -4947,241 +4930,226 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public TieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration tieredWithProration - ) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFilters(BulkWithFilters bulkWithFilters) + : base(bulkWithFilters) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public BulkWithFilters(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] - TieredWithProration(FrozenDictionary rawData) + BulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw - : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProration.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class TieredWithProrationCadenceConverter - : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BulkWithFiltersConfig : JsonModel { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence 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.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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("filters"); + } + init + { + this._rawData.Set>( + "filters", + ImmutableArray.ToImmutableArray(value) + ); + } } -} -/// -/// 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 -{ /// - /// 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 - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + 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 TieredWithProrationConfig() { } + public BulkWithFiltersConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) + : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + BulkWithFiltersConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Filter : JsonModel { /// - /// Inclusive tier starting value + /// Event property key to filter on /// - public required string TierLowerBound + public required string PropertyKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("property_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + 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 /// @@ -5195,58 +5163,129 @@ public required string UnitAmount 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.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public TieredWithProrationConfigTier() { } + public Tier() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) + : base(tier) { } +#pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public Tier(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + Tier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier.FromRawUnchecked( - rawData + 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(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfigConverter) -)] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5263,7 +5302,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5272,7 +5311,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5281,7 +5320,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -5290,7 +5329,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 +5350,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 +5370,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 +5381,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5363,7 +5402,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of BulkWithFiltersConversionRateConfig" ); } } @@ -5372,7 +5411,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 +5422,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5399,16 +5438,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 BulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5427,18 +5466,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 BulkWithFiltersConversionRateConfig" ); } 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(BulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5446,13 +5483,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 BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5481,12 +5531,10 @@ JsonSerializerOptions 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 +5551,10 @@ JsonSerializerOptions 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 +5563,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( - element - ); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -5535,60 +5579,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +public sealed record class MatrixWithThresholdDiscounts : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for matrix_with_threshold_discounts pricing /// - public required string ItemID + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// @@ -5676,12 +5711,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 MatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5772,6 +5807,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5811,12 +5859,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { @@ -5834,37 +5882,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public MatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + MatrixWithThresholdDiscounts(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5872,25 +5922,19 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( + public MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence { Annual, SemiAnnual, @@ -5900,10 +5944,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence Read( + public override MatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5911,49 +5955,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" => MatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence value, + MatrixWithThresholdDiscountsCadence value, JsonSerializerOptions options ) { @@ -5961,26 +5975,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", + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5991,99 +5991,138 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for matrix_with_threshold_discounts pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfigFromRaw + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Unit price used for usage that does not match any defined matrix cell. /// - public required string GroupingKey + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("default_unit_amount"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("default_unit_amount", value); } } /// - /// The maximum amount to charge each group + /// First matrix dimension key. /// - public required string MaximumCharge + public required string FirstDimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("first_dimension"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("first_dimension", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// Per-cell unit prices. /// - public required string MinimumCharge + public required IReadOnlyList MatrixValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullStruct>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("minimum_charge", value); } } /// - /// The base price charged per group + /// Optional second matrix dimension key. /// - public required string PerUnitRate + public string? SecondDimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNullableClass("second_dimension"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("second_dimension", value); } } - /// - public override void Validate() + public IReadOnlyList? ThresholdDiscountGroups { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; - } + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) + { + return; + } - public GroupedWithMinMaxThresholdsConfig() { } + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig + ) + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6091,22 +6130,205 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public MatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 + + public MatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixValueFromRaw : IFromRawJson +{ + /// + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public ThresholdDiscountGroup() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 + + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdDiscountGroupFromRaw : IFromRawJson +{ + /// + public ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6123,7 +6345,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6132,7 +6354,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6141,7 +6363,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) { this._element = element; } @@ -6150,7 +6372,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 +6393,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 +6413,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 +6424,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6223,7 +6445,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" ); } } @@ -6232,7 +6454,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 +6465,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6259,16 +6481,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 MatrixWithThresholdDiscountsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6287,18 +6509,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 MatrixWithThresholdDiscountsConversionRateConfig" ); } 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(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6306,13 +6526,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 MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6341,12 +6574,10 @@ JsonSerializerOptions 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 +6594,10 @@ JsonSerializerOptions 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 +6606,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new MatrixWithThresholdDiscountsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig value, + MatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6394,48 +6621,22 @@ 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 TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// Configuration for cumulative_grouped_allocation pricing - /// - 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); } } /// @@ -6477,6 +6678,21 @@ public required string 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. /// @@ -6536,12 +6752,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 TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6632,6 +6848,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6671,18 +6900,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + 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(); @@ -6694,37 +6923,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public TieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public TieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + TieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6732,25 +6963,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadenceConverter) -)] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence { Annual, SemiAnnual, @@ -6760,10 +6984,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6771,49 +6994,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" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -6821,26 +7014,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", + 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)) ), @@ -6851,57 +7030,112 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class TieredWithProrationConfig : JsonModel { /// - /// The overall allocation across all groups + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string CumulativeAllocation + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("cumulative_allocation", value); } } - /// - /// The allocation per individual group - /// - public required string GroupAllocation + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + item.Validate(); } - init { this._rawData.Set("group_allocation", value); } } + 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 +{ /// - /// The event property used to group usage before applying allocations + /// Inclusive tier starting value /// - public required string GroupingKey + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Amount per unit /// public required string UnitAmount { @@ -6916,34 +7150,35 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.TierLowerBound; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public TieredWithProrationConfigTier() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier ) - : base(cumulativeGroupedAllocationConfig) { } + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + TieredWithProrationConfigTier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6951,22 +7186,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6983,7 +7212,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6992,7 +7221,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7001,7 +7230,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public TieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -7010,7 +7239,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 +7260,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 +7280,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 +7291,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7083,7 +7312,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } } @@ -7092,7 +7321,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 +7332,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7119,16 +7348,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 TieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7147,18 +7376,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 TieredWithProrationConversionRateConfig" ); } 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(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7166,13 +7393,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 TieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7201,12 +7441,10 @@ JsonSerializerOptions 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 +7461,10 @@ JsonSerializerOptions 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 +7473,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7255,54 +7489,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Minimum, - global::Orb.Models.Beta.ExternalPlanID.MinimumFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class Minimum : JsonModel +public sealed record class GroupedWithMinMaxThresholds : 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); } } /// - /// The id of the item the price will be associated with. + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required string ItemID + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.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); } } /// @@ -7390,12 +7621,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 GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7486,6 +7717,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7525,9 +7769,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -7543,35 +7792,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public Minimum(global::Orb.Models.Beta.ExternalPlanID.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7579,19 +7832,19 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Minimum.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -7601,10 +7854,10 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7612,19 +7865,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" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -7632,12 +7885,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", + 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)) ), @@ -7648,101 +7901,119 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.MinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.MinimumConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The minimum amount to apply + /// The event property used to group before applying thresholds /// - public required string MinimumAmount + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The maximum amount to charge each group /// - public bool? Prorated + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init + init { this._rawData.Set("maximum_charge", value); } + } + + /// + /// The minimum amount to charge each group, regardless of usage + /// + public required string MinimumCharge + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_charge"); + } + init { this._rawData.Set("minimum_charge", value); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public MinimumConfig() { } + public GroupedWithMinMaxThresholdsConfig() { } - public MinimumConfig(global::Orb.Models.Beta.ExternalPlanID.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.MinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7759,7 +8030,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7768,7 +8039,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7777,7 +8048,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -7786,7 +8057,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 +8078,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 +8098,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 +8109,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7859,7 +8130,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -7868,7 +8139,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 +8150,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7895,16 +8166,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 GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7923,18 +8194,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 GroupedWithMinMaxThresholdsConversionRateConfig" ); } 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(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7942,13 +8211,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 GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7977,12 +8259,10 @@ JsonSerializerOptions 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 +8279,10 @@ JsonSerializerOptions 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 +8291,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -8031,28 +8307,40 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Percent, - global::Orb.Models.Beta.ExternalPlanID.PercentFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class Percent : JsonModel +public sealed record class CumulativeGroupedAllocation : 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 + /// + 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. /// @@ -8092,21 +8380,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -8166,12 +8439,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 CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8262,6 +8535,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -8301,13 +8587,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8319,35 +8610,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public Percent(global::Orb.Models.Beta.ExternalPlanID.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8355,19 +8650,19 @@ IReadOnlyDictionary rawData } } -class PercentFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Percent.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -8377,10 +8672,10 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8388,19 +8683,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" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -8408,12 +8703,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", + 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)) ), @@ -8424,79 +8719,119 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.PercentConfig, - global::Orb.Models.Beta.ExternalPlanID.PercentConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class PercentConfig : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The overall allocation across all groups /// - public required double Percent + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("percent", value); } + 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.Percent; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public PercentConfig() { } + public CumulativeGroupedAllocationConfig() { } - public PercentConfig(global::Orb.Models.Beta.ExternalPlanID.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.PercentConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8513,7 +8848,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8522,7 +8857,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8531,7 +8866,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -8540,7 +8875,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 +8896,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 +8916,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 +8927,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8613,7 +8948,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -8622,7 +8957,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 +8968,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8649,16 +8984,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8677,18 +9012,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 CumulativeGroupedAllocationConversionRateConfig" ); } 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(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8696,13 +9029,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8731,12 +9077,10 @@ JsonSerializerOptions 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 +9097,10 @@ JsonSerializerOptions 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 +9109,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -8784,45 +9124,37 @@ 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 DailyCreditAllowance : 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 + /// Configuration for daily_credit_allowance pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig EventOutputConfig + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -8923,12 +9255,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 DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9019,6 +9351,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +9403,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("event_output") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -9081,35 +9426,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public EventOutput(global::Orb.Models.Beta.ExternalPlanID.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9117,19 +9466,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutput.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -9139,10 +9488,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9150,19 +9498,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" => DailyCreditAllowanceCadence.Annual, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "one_time" => DailyCreditAllowanceCadence.OneTime, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -9170,13 +9518,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", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9187,115 +9534,239 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class EventOutputConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string UnitRatingKey + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("daily_allowance", 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. + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public string? DefaultUnitRate + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("default_unit_amount"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("default_unit_amount", 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. + /// One or two event property values to evaluate matrix groups by /// - public string? GroupingKey + public required IReadOnlyList Dimensions { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } } - public EventOutputConfig() { } - - public EventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig eventOutputConfig - ) - : base(eventOutputConfig) { } - - public EventOutputConfig(IReadOnlyDictionary rawData) + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public DailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class DailyCreditAllowanceConfigFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class DailyCreditAllowanceConfigMatrixValue : JsonModel +{ + /// + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Credits charged per unit of usage matching the specified dimension_values + /// + 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.DimensionValues; + _ = this.UnitAmount; + } + + public DailyCreditAllowanceConfigMatrixValue() { } +#pragma warning disable CS8618 [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue + ) + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) { - this.UnitRatingKey = unitRatingKey; + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputConfigFromRaw - : IFromRawJson +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfigConverter) -)] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9312,7 +9783,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9321,7 +9792,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9330,7 +9801,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -9339,7 +9810,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 +9831,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 +9851,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 +9862,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9412,7 +9883,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -9421,7 +9892,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 +9903,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9448,16 +9919,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9476,18 +9947,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9495,13 +9964,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9530,12 +10012,10 @@ JsonSerializerOptions 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 +10032,10 @@ JsonSerializerOptions 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 +10044,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - element - ); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9583,254 +10059,341 @@ 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 MeteredAllowance : 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; + init { this._rawData.Set("item_id", value); } } - public RemoveAdjustment() { } - - public RemoveAdjustment( - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment removeAdjustment - ) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// Configuration for metered_allowance pricing + /// + public required MeteredAllowanceConfig MeteredAllowanceConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); + } + init { this._rawData.Set("metered_allowance_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + /// + /// The pricing model type + /// + public JsonElement ModelType { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// The name of the price. + /// + public required string Name { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_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. + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. /// - public required string PriceID + public bool? BilledInAdvance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNullableStruct("billed_in_advance"); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("billed_in_advance", value); } } /// - /// The phase to remove this price from. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public long? PlanPhaseOrder + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - /// - public override void Validate() + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - _ = this.PriceID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public RemovePrice() { } - - public RemovePrice(global::Orb.Models.Beta.ExternalPlanID.RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + /// + /// An alias for the price. + /// + public string? ExternalPriceID { - this.PriceID = priceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } -} -class RemovePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemovePrice.FromRawUnchecked(rawData); -} + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } -[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. + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment Adjustment + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// The ID of the license type to associate with this price. /// - public required string ReplacesAdjustmentID + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableClass("license_type_id"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("license_type_id", value); } } /// - /// The phase to replace this adjustment from. + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. /// - public long? PlanPhaseOrder + public IReadOnlyDictionary? Metadata { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass>("metadata"); } - init { this._rawData.Set("plan_phase_order", value); } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + this.Cadence.Validate(); + _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public ReplaceAdjustment() { } + public MeteredAllowance() + { + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); + } - public ReplaceAdjustment( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment replaceAdjustment - ) - : base(replaceAdjustment) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9838,208 +10401,313 @@ IReadOnlyDictionary rawData } } -class ReplaceAdjustmentFromRaw - : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the plan. +/// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { - public object? Value { get; } = null; + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - JsonElement? _element = null; +sealed class MeteredAllowanceCadenceConverter : JsonConverter +{ + public override MeteredAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MeteredAllowanceCadence.Annual, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "one_time" => MeteredAllowanceCadence.OneTime, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), + }; + } - public JsonElement Json + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for metered_allowance pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel +{ + /// + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); } + init { this._rawData.Set("allowance_grouping_value", value); } } - public string? Currency + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue { 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.GetNotNullClass("consumption_grouping_value"); } + init { this._rawData.Set("consumption_grouping_value", value); } } - public bool? IsInvoiceLevel + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey { 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.GetNotNullClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + 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 ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName { - this.Value = value; - this._element = element; - } + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + this._rawData.Set("allowance_display_name", value); + } + } + + /// + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + /// + public string? ConsumptionDisplayName { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); + } } - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public MeteredAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 + + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplaceAdjustmentAdjustment(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowanceConfig(FrozenDictionary rawData) { - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 static MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - value = this.Value as NewPercentageDiscount; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) +class MeteredAllowanceConfigFromRaw : IFromRawJson +{ + /// + public MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { - value = this.Value as NewAmountDiscount; - return value != null; + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig(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 +10718,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 MeteredAllowanceConversionRateConfig" ); } } @@ -10095,7 +10748,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 +10759,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 MeteredAllowanceConversionRateConfig" ), }; } - 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 MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMaximum value + public static implicit operator MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value ) => new(value); /// @@ -10171,24 +10803,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 MeteredAllowanceConversionRateConfig" ); } - 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10196,147 +10820,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? Read( + public override MeteredAllowanceConversionRateConfig? 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 MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -10344,2927 +10915,8309 @@ 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 Percent : 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. + /// 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); } + init { this._rawData.Set("model_type", value); } } /// - /// New plan price request body params. + /// The name of the price. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Price + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" - ); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("name", value); } } - /// - public override void Validate() + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } } - public ReplacePrice() { } - - public ReplacePrice(global::Orb.Models.Beta.ExternalPlanID.ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary 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 disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", 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; + /// + /// 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); } + } - JsonElement? _element = null; + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, 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 JsonElement Json + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public string ItemID + /// + /// An alias for the price. + /// + public string? ExternalPriceID { 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("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public string Name + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { 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.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public string? BillableMetricID + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { 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("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public bool? BilledInAdvance + /// + /// Within each 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.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( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public double? ConversionRate + /// + /// User-specified key/value pairs for the resource. Individual keys can be 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.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>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public string? Currency + /// + /// 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.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("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + public override void Validate() { - get + this.Cadence.Validate(); + _ = this.ItemID; + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { - 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 - ); + 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 string? ExternalPriceID + 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 + ); + } +} + +/// +/// 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 { - 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.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } - public double? FixedPriceQuantity + /// + 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 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 + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } } - public string? InvoiceGroupingKey + public PercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { - get - { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey + 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); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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; + 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(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); + } +} + +[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(JsonModelConverter< + ReplacePriceLicenseAllocationPrice, + ReplacePriceLicenseAllocationPriceFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPrice : 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 required ApiEnum ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// 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 ReplacePriceLicenseAllocationPriceConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + 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.ModelType.Validate(); + _ = 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 ReplacePriceLicenseAllocationPrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPrice replacePriceLicenseAllocationPrice + ) + : base(replacePriceLicenseAllocationPrice) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPrice(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceFromRaw : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPrice.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePriceLicenseAllocationPriceCadenceConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePriceLicenseAllocationPriceCadence.Annual, + "semi_annual" => ReplacePriceLicenseAllocationPriceCadence.SemiAnnual, + "monthly" => ReplacePriceLicenseAllocationPriceCadence.Monthly, + "quarterly" => ReplacePriceLicenseAllocationPriceCadence.Quarterly, + "one_time" => ReplacePriceLicenseAllocationPriceCadence.OneTime, + "custom" => ReplacePriceLicenseAllocationPriceCadence.Custom, + _ => (ReplacePriceLicenseAllocationPriceCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceCadence.Annual => "annual", + ReplacePriceLicenseAllocationPriceCadence.SemiAnnual => "semi_annual", + ReplacePriceLicenseAllocationPriceCadence.Monthly => "monthly", + ReplacePriceLicenseAllocationPriceCadence.Quarterly => "quarterly", + ReplacePriceLicenseAllocationPriceCadence.OneTime => "one_time", + ReplacePriceLicenseAllocationPriceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPriceLicenseAllocation, + ReplacePriceLicenseAllocationPriceLicenseAllocationFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPriceLicenseAllocation : JsonModel +{ + /// + /// The amount of credits granted per active license per cadence. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } + + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } + + public ReplacePriceLicenseAllocationPriceLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPriceLicenseAllocation( + ReplacePriceLicenseAllocationPriceLicenseAllocation replacePriceLicenseAllocationPriceLicenseAllocation + ) + : base(replacePriceLicenseAllocationPriceLicenseAllocation) { } +#pragma warning restore CS8618 + + public ReplacePriceLicenseAllocationPriceLicenseAllocation( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePriceLicenseAllocationPriceLicenseAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePriceLicenseAllocationPriceLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePriceLicenseAllocationPriceLicenseAllocationFromRaw + : IFromRawJson +{ + /// + public ReplacePriceLicenseAllocationPriceLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePriceLicenseAllocationPriceLicenseAllocation.FromRawUnchecked(rawData); +} + +/// +/// The pricing model type +/// +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceModelTypeConverter))] +public enum ReplacePriceLicenseAllocationPriceModelType +{ + Unit, +} + +sealed class ReplacePriceLicenseAllocationPriceModelTypeConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceModelType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unit" => ReplacePriceLicenseAllocationPriceModelType.Unit, + _ => (ReplacePriceLicenseAllocationPriceModelType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceModelType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePriceLicenseAllocationPriceModelType.Unit => "unit", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceConversionRateConfigConverter))] +public record class ReplacePriceLicenseAllocationPriceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePriceLicenseAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePriceLicenseAllocationPriceConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 ReplacePriceLicenseAllocationPriceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceConversionRateConfig 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (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( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePriceMeteredAllowance 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.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `ReplacePricePriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out ReplacePricePriceMatrixWithThresholdDiscounts? value + ) + { + value = this.Value as ReplacePricePriceMatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the 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.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out ReplacePricePriceDailyCreditAllowance? value + ) + { + value = this.Value as ReplacePricePriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] out ReplacePricePriceMeteredAllowance? value + ) + { + value = this.Value as ReplacePricePriceMeteredAllowance; + return value != null; + } + + /// + /// Returns true and sets the 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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + 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 ReplacePricePriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(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 ReplacePricePriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case ReplacePricePriceMeteredAllowance value: + meteredAllowance(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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Func meteredAllowance, + 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), + ReplacePricePriceMatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts( + 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 + ), + ReplacePricePriceDailyCreditAllowance value => dailyCreditAllowance(value), + ReplacePricePriceMeteredAllowance value => meteredAllowance(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( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceMeteredAllowance 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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, + ReplacePricePriceMatrixWithThresholdDiscounts _ => 14, + ReplacePricePriceTieredWithProration _ => 15, + NewPlanUnitWithProrationPrice _ => 16, + NewPlanGroupedAllocationPrice _ => 17, + NewPlanBulkWithProrationPrice _ => 18, + NewPlanGroupedWithProratedMinimumPrice _ => 19, + NewPlanGroupedWithMeteredMinimumPrice _ => 20, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 21, + NewPlanMatrixWithDisplayNamePrice _ => 22, + NewPlanGroupedTieredPackagePrice _ => 23, + NewPlanMaxGroupTieredPackagePrice _ => 24, + NewPlanScalableMatrixWithUnitPricingPrice _ => 25, + NewPlanScalableMatrixWithTieredPricingPrice _ => 26, + NewPlanCumulativeGroupedBulkPrice _ => 27, + ReplacePricePriceCumulativeGroupedAllocation _ => 28, + ReplacePricePriceDailyCreditAllowance _ => 29, + ReplacePricePriceMeteredAllowance _ => 30, + NewPlanMinimumCompositePrice _ => 31, + ReplacePricePricePercent _ => 32, + ReplacePricePriceEventOutput _ => 33, + _ => -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 "matrix_with_threshold_discounts": + { + 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 NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newPlanPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMatrix: (x) => x.InvoicingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } + 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 string? ReferenceID - { - get - { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } + 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 ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + 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 + } - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + return new(element); + } + default: + { + return new ReplacePricePrice(element); + } + } } - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public override void Write( + Utf8JsonWriter writer, + ReplacePricePrice? value, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize(writer, value?.Json, options); } +} - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } } - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } } - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) + /// + /// The pricing model type + /// + public JsonElement ModelType { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } } - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + /// + /// The name of the price. + /// + public required string Name { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) + /// + /// An alias for the price. + /// + public string? ExternalPriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice 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 ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + 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 ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + public ReplacePricePriceBulkWithFilters() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - { - this.Value = value; - this._element = element; - } + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value, - JsonElement? element = null - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, - JsonElement? element = null + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(JsonElement element) - { - this._element = element; - } +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// Property filters to apply (all must match) /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public required IReadOnlyList Filters { - value = this.Value as NewPlanUnitPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", 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.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Bulk tiers for rating based on total usage volume /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public required IReadOnlyList Tiers { - value = this.Value as NewPlanTieredPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", 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.TryPickNewPlanBulk(out var value)) { - /// // `value` is of type `NewPlanBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + /// + public override void Validate() { - value = this.Value as NewPlanBulkPrice; - return value != null; + 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 + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters? value + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - value = - this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters; - return value != null; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// Event property key to filter on /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public required string PropertyKey { - value = this.Value as NewPlanPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_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.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Event property value to match /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public required string PropertyValue { - value = this.Value as NewPlanMatrixPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", 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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + /// + public override void Validate() { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; + _ = this.PropertyKey; + _ = this.PropertyValue; } - /// - /// Returns true and sets the 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 + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; - } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData ) { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; + this._rawData = new(rawData); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData ) { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// Amount per unit /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public required string UnitAmount { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_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.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The lower bound for this tier /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + 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() { - value = this.Value as NewPlanUnitWithPercentPrice; - return value != null; + _ = this.UnitAmount; + _ = this.TierLowerBound; } - /// - /// Returns true and sets the 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 + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData ) { - value = this.Value as NewPlanMatrixWithAllocationPrice; - return value != null; + this._rawData = new(rawData); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration? value +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData ) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the 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 + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData ) { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + this.UnitAmount = unitAmount; } +} - /// - /// Returns true and sets the 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 +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; + 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), + }; } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + 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 + ); } +} - /// - /// Returns true and sets the 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 - ) +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds? value + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null ) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null ) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + this.Value = value; + this._element = element; + } + + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + { + this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// 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.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewPlanGroupedTieredPackagePrice; + value = 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; + 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + public void Switch( + System::Action unit, + System::Action tiered ) { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } } /// - /// 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; } + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscounts, + ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscounts : 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); } + } + + /// + /// Configuration for matrix_with_threshold_discounts pricing + /// + public required ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// + /// The pricing model type /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation? value - ) + public JsonElement ModelType { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// + /// The name of the price. /// - public bool TryPickMinimum( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum? value - ) + public required string Name { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum; - 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanMinimumCompositePrice; - 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.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent` - /// 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 TryPickPercent( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent? value - ) + public bool? BilledInAdvance { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; - 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", 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) => {...} - /// ); - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - 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 double? ConversionRate { - 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.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } + init { this._rawData.Set("conversion_rate_config", 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) => {...} - /// ); - /// - /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - 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 string? Currency { - return this.Value switch + get { - 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" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitPrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkPrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixPrice value - ) => new(value); + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanThresholdTotalAmountPrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackagePrice 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice value - ) => new(value); + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscounts( + ReplacePricePriceMatrixWithThresholdDiscounts replacePricePriceMatrixWithThresholdDiscounts + ) + : base(replacePricePriceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithPercentPrice value - ) => new(value); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithAllocationPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value - ) => new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceMatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter))] +public enum ReplacePricePriceMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); +sealed class ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom, + _ => (ReplacePricePriceMatrixWithThresholdDiscountsCadence)(-1), + }; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual => "annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly => "monthly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime => "one_time", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base(replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value - ) => new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value - ) => new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : JsonModel +{ + public required string FirstDimensionValue { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension_value"); } - 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() - ); + init { this._rawData.Set("first_dimension_value", value); } + } + + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? other) + public string? SecondDimensionValue { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } } - public override int GetHashCode() + /// + public override void Validate() { - return 0; + _ = this.FirstDimensionValue; + _ = this.UnitAmount; + _ = this.SecondDimensionValue; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } } -sealed class ReplacePricePriceConverter - : JsonConverter +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try + get { - modelType = element.GetProperty("model_type").GetString(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); } - catch + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get { - modelType = null; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } - switch (modelType) + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (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 - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", 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 - } + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", 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 - } + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", 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 - } + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } - 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 - } + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - 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 - } +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} - 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(ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `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_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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `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 "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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } - 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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - 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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public virtual bool Equals( + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - 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 - } + public override int GetHashCode() + { + return 0; + } - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - return new(element); - } - case "minimum_composite": + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + 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) - { - // 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) + catch (JsonException) { // ignore } return new(element); } - case "event_output": + case "tiered": { 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 } @@ -13273,60 +19226,41 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); + return new ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : 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 + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -13371,6 +19305,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. /// @@ -13430,12 +19379,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -13526,6 +19475,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19526,19 @@ 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") + 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(); @@ -13588,146 +19550,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; - _ = this.ReferenceID; - } - - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public ReplacePricePriceBulkWithFilters( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } - - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } + _ = this.ReferenceID; } - /// - public override void Validate() + public ReplacePricePriceTieredWithProration() { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13735,70 +19592,127 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - 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 ); + } } /// -/// Configuration for a single property filter +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// Event property key to filter on + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string PropertyKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData ) { @@ -13807,7 +19721,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -13815,79 +19729,89 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel { /// - /// Amount per unit + /// Inclusive tier starting value /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The lower bound for this tier + /// Amount per unit /// - public string? TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.UnitAmount; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -13896,7 +19820,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -13904,162 +19828,27 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence)( - -1 - ), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14076,7 +19865,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14085,7 +19874,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14094,7 +19883,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -14103,7 +19892,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig(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. /// /// /// @@ -14124,7 +19913,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. /// /// /// @@ -14144,7 +19933,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. /// /// @@ -14155,8 +19944,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14176,7 +19965,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -14185,7 +19974,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. /// /// @@ -14196,8 +19985,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14212,16 +20001,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14240,32 +20029,43 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "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.ReplacePricePriceBulkWithFiltersConversionRateConfig? 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() { return 0; } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14294,12 +20094,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14316,12 +20114,10 @@ JsonSerializerOptions 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,16 +20126,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -14349,33 +20143,42 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// 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. /// @@ -14415,21 +20218,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 +20277,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14585,6 +20373,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -14624,18 +20425,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -14647,37 +20448,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceTieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceGroupedWithMinMaxThresholds( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14685,25 +20492,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadenceConverter) -)] -public enum ReplacePricePriceTieredWithProrationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -14713,10 +20515,10 @@ public enum ReplacePricePriceTieredWithProrationCadence Custom, } -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14724,52 +20526,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence)( - -1 - ), + "annual" => 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.ReplacePricePriceTieredWithProrationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -14777,42 +20546,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom => "custom", + 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)) ), @@ -14823,153 +20562,89 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// The event property used to group before applying thresholds /// - public required IReadOnlyList Tiers + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + /// + /// The maximum amount to charge each group + /// + public required string MaximumCharge { - foreach (var item in this.Tiers) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("maximum_charge"); } + init { this._rawData.Set("maximum_charge", value); } } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig - ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - : JsonModel -{ /// - /// Inclusive tier starting value + /// The minimum amount to charge each group, regardless of usage /// - public required string TierLowerBound + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// Amount per unit + /// 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -14978,7 +20653,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -14986,8 +20661,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14995,22 +20670,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfigConverter) -)] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15027,7 +20700,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15036,7 +20709,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15045,7 +20718,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15054,7 +20727,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 +20748,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 +20768,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 +20779,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15127,7 +20800,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -15136,7 +20809,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 +20820,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15163,16 +20836,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15191,18 +20864,18 @@ 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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } 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); - } + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15210,13 +20883,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15245,12 +20931,10 @@ JsonSerializerOptions 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 +20951,10 @@ JsonSerializerOptions 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,7 +20963,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -15290,7 +20972,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -15300,46 +20982,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : 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 + /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -15440,12 +21116,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15536,6 +21212,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +21264,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -15598,39 +21287,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( + public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15638,25 +21331,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -15666,10 +21354,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15677,52 +21365,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" => 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.ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -15730,42 +21385,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", + 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)) ), @@ -15776,86 +21401,89 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -15864,7 +21492,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -15872,8 +21500,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15881,22 +21509,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15913,7 +21539,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15922,7 +21548,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15931,7 +21557,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15940,7 +21566,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 +21587,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 +21607,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 +21618,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16013,7 +21639,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -16022,7 +21648,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 +21659,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16049,16 +21675,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16077,18 +21703,18 @@ 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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } 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); - } + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16096,13 +21722,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16131,12 +21770,10 @@ JsonSerializerOptions 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 +21790,10 @@ JsonSerializerOptions 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,7 +21802,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -16176,7 +21811,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16186,46 +21821,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceDailyCreditAllowance, + ReplacePricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceDailyCreditAllowance : 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 daily_credit_allowance pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -16326,12 +21955,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16422,6 +22051,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22103,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -16484,39 +22126,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public ReplacePricePriceCumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowance( + ReplacePricePriceDailyCreditAllowance replacePricePriceDailyCreditAllowance ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceDailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceDailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16524,25 +22168,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceDailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadenceConverter) -)] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceCadenceConverter))] +public enum ReplacePricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -16552,10 +22191,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16563,52 +22202,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" => ReplacePricePriceDailyCreditAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceDailyCreditAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceDailyCreditAllowanceCadence.OneTime, + "custom" => ReplacePricePriceDailyCreditAllowanceCadence.Custom, + _ => (ReplacePricePriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -16616,42 +22222,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", + ReplacePricePriceDailyCreditAllowanceCadence.Annual => "annual", + ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceDailyCreditAllowanceCadence.Monthly => "monthly", + ReplacePricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceDailyCreditAllowanceCadence.OneTime => "one_time", + ReplacePricePriceDailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16662,58 +22238,189 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -16728,20 +22435,21 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -16750,7 +22458,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -16758,8 +22466,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16767,22 +22475,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16799,7 +22505,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16808,7 +22514,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16817,7 +22523,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16826,7 +22532,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 +22553,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 +22573,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 +22584,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16899,7 +22605,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -16908,7 +22614,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 +22625,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16935,16 +22641,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16963,18 +22669,16 @@ 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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } 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); - } + public virtual bool Equals(ReplacePricePriceDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16982,13 +22686,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17017,12 +22734,10 @@ JsonSerializerOptions 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 +22754,10 @@ JsonSerializerOptions 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,16 +22766,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( - element - ); + return new ReplacePricePriceDailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -17072,28 +22783,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumFromRaw + ReplacePricePriceMeteredAllowance, + ReplacePricePriceMeteredAllowanceFromRaw >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceMeteredAllowance : 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); } @@ -17113,18 +22818,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -17212,12 +22917,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 ReplacePricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17308,6 +23013,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -17348,8 +23066,13 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -17365,37 +23088,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public ReplacePricePriceMinimum( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum replacePricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowance( + ReplacePricePriceMeteredAllowance replacePricePriceMeteredAllowance ) - : base(replacePricePriceMinimum) { } + : base(replacePricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17403,22 +23130,19 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw - : IFromRawJson +class ReplacePricePriceMeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadenceConverter) -)] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceCadenceConverter))] +public enum ReplacePricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -17428,10 +23152,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17439,49 +23163,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" => ReplacePricePriceMeteredAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceMeteredAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceMeteredAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceMeteredAllowanceCadence.OneTime, + "custom" => ReplacePricePriceMeteredAllowanceCadence.Custom, + _ => (ReplacePricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence value, + ReplacePricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -17489,18 +23183,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", + ReplacePricePriceMeteredAllowanceCadence.Annual => "annual", + ReplacePricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMeteredAllowanceCadence.Monthly => "monthly", + ReplacePricePriceMeteredAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceMeteredAllowanceCadence.OneTime => "one_time", + ReplacePricePriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17511,38 +23199,103 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig, + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -17551,69 +23304,68 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig replacePricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceMeteredAllowanceMeteredAllowanceConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfigConverter) -)] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17630,7 +23382,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17639,7 +23391,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17648,7 +23400,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -17657,7 +23409,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 +23430,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 +23450,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 +23461,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17730,7 +23482,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -17739,7 +23491,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 +23502,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17766,16 +23518,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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17794,18 +23546,16 @@ 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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } 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); - } + public virtual bool Equals(ReplacePricePriceMeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17813,13 +23563,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 ReplacePricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17848,12 +23611,10 @@ JsonSerializerOptions 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 +23631,10 @@ JsonSerializerOptions 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,16 +23643,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( - element - ); + return new ReplacePricePriceMeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -17902,30 +23659,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 +23720,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 +23791,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 +23887,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +23957,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18205,10 +23967,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 +23988,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 +23997,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 +24020,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 +24030,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 +24050,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 +24070,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 +24097,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 +24118,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +24135,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 +24188,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 +24209,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 +24229,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 +24240,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18548,7 +24270,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 +24281,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18580,11 +24302,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 +24331,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 +24342,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 +24390,10 @@ JsonSerializerOptions 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 +24410,10 @@ JsonSerializerOptions 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 +24422,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 +24438,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 +24460,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 +24570,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 +24666,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +24741,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19019,10 +24751,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 +24772,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 +24781,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 +24804,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 +24814,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 +24834,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 +24854,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 +24912,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 +24935,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +24952,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 +25005,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 +25026,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 +25046,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 +25057,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19414,7 +25087,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 +25098,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19446,11 +25119,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 +25148,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 +25159,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 +25207,10 @@ JsonSerializerOptions 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 +25227,10 @@ JsonSerializerOptions 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 +25239,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..94041a81b 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) { @@ -318,64 +321,68 @@ public required IReadOnlyList CustomerBalanceTransac /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +900,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 +1011,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 +1138,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 +1312,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 +1535,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 +1802,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 +1965,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 +1988,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 +2011,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 +2034,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 +2055,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 +2075,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 +2086,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 +2131,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 +2142,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 +2215,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 +2226,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 +2276,10 @@ JsonSerializerOptions 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 +2296,10 @@ JsonSerializerOptions 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 +2317,10 @@ JsonSerializerOptions 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 +2337,10 @@ JsonSerializerOptions 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 +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 } @@ -2438,7 +2466,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 +2487,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 +2508,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 +2528,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 +2539,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 +2572,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 +2583,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2606,10 +2634,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 +2645,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 +2693,10 @@ JsonSerializerOptions 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 +2713,10 @@ JsonSerializerOptions 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 +2733,10 @@ JsonSerializerOptions 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 +2871,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..efa9d20c6 --- /dev/null +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs @@ -0,0 +1,140 @@ +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), 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. +/// +/// For credit blocks created by subscription allocation prices, this endpoint +/// returns the subscription invoice containing the allocation line item that created +/// the block. +/// +/// If the credit block was not purchased (e.g., manual increment), 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..2764872fd 100644 --- a/src/Orb/Models/CustomerTaxID.cs +++ b/src/Orb/Models/CustomerTaxID.cs @@ -52,62 +52,66 @@ namespace Orb.Models; /// | | 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 | | 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 | +/// scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number | | 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 | | Gibraltar | `gi_tin` | Gibraltar +/// Tax Identification 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 +/// | | Italy | `it_cf` | Italian Codice Fiscale 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 | | Paraguay | `py_ruc` | Paraguayan +/// RUC 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 | | Sri Lanka | `lk_vat` | +/// Sri Lanka 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 +156,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) { @@ -216,9 +223,9 @@ public enum Country Co, Cr, Cv, - De, Cy, Cz, + De, Dk, Do, Ec, @@ -228,9 +235,11 @@ public enum Country Et, Eu, Fi, + Fo, Fr, GB, Ge, + Gi, Gn, Gr, Hk, @@ -250,6 +259,7 @@ public enum Country Kz, La, Li, + Lk, Lt, Lu, Lv, @@ -271,6 +281,7 @@ public enum Country Ph, Pl, Pt, + Py, Ro, Rs, Ru, @@ -340,9 +351,9 @@ JsonSerializerOptions options "CO" => Country.Co, "CR" => Country.Cr, "CV" => Country.Cv, - "DE" => Country.De, "CY" => Country.Cy, "CZ" => Country.Cz, + "DE" => Country.De, "DK" => Country.Dk, "DO" => Country.Do, "EC" => Country.Ec, @@ -352,9 +363,11 @@ JsonSerializerOptions options "ET" => Country.Et, "EU" => Country.Eu, "FI" => Country.Fi, + "FO" => Country.Fo, "FR" => Country.Fr, "GB" => Country.GB, "GE" => Country.Ge, + "GI" => Country.Gi, "GN" => Country.Gn, "GR" => Country.Gr, "HK" => Country.Hk, @@ -374,6 +387,7 @@ JsonSerializerOptions options "KZ" => Country.Kz, "LA" => Country.La, "LI" => Country.Li, + "LK" => Country.Lk, "LT" => Country.Lt, "LU" => Country.Lu, "LV" => Country.Lv, @@ -395,6 +409,7 @@ JsonSerializerOptions options "PH" => Country.Ph, "PL" => Country.Pl, "PT" => Country.Pt, + "PY" => Country.Py, "RO" => Country.Ro, "RS" => Country.Rs, "RU" => Country.Ru, @@ -462,9 +477,9 @@ public override void Write(Utf8JsonWriter writer, Country value, JsonSerializerO Country.Co => "CO", Country.Cr => "CR", Country.Cv => "CV", - Country.De => "DE", Country.Cy => "CY", Country.Cz => "CZ", + Country.De => "DE", Country.Dk => "DK", Country.Do => "DO", Country.Ec => "EC", @@ -474,9 +489,11 @@ public override void Write(Utf8JsonWriter writer, Country value, JsonSerializerO Country.Et => "ET", Country.Eu => "EU", Country.Fi => "FI", + Country.Fo => "FO", Country.Fr => "FR", Country.GB => "GB", Country.Ge => "GE", + Country.Gi => "GI", Country.Gn => "GN", Country.Gr => "GR", Country.Hk => "HK", @@ -496,6 +513,7 @@ public override void Write(Utf8JsonWriter writer, Country value, JsonSerializerO Country.Kz => "KZ", Country.La => "LA", Country.Li => "LI", + Country.Lk => "LK", Country.Lt => "LT", Country.Lu => "LU", Country.Lv => "LV", @@ -517,6 +535,7 @@ public override void Write(Utf8JsonWriter writer, Country value, JsonSerializerO Country.Ph => "PH", Country.Pl => "PL", Country.Pt => "PT", + Country.Py => "PY", Country.Ro => "RO", Country.Rs => "RS", Country.Ru => "RU", @@ -600,8 +619,10 @@ public enum CustomerTaxIDType EsCif, EtTin, EuOssVat, + FoVat, GBVat, GeVat, + GiTin, GnNif, HkBr, HrOib, @@ -610,6 +631,7 @@ public enum CustomerTaxIDType IlVat, InGst, IsVat, + ItCf, JpCn, JpRn, JpTrn, @@ -621,6 +643,7 @@ public enum CustomerTaxIDType LaTin, LiUid, LiVat, + LkVat, MaVat, MdVat, MePib, @@ -638,6 +661,8 @@ public enum CustomerTaxIDType OmVat, PeRuc, PhTin, + PlNip, + PyRuc, RoTin, RsPib, RuInn, @@ -722,8 +747,10 @@ JsonSerializerOptions options "es_cif" => CustomerTaxIDType.EsCif, "et_tin" => CustomerTaxIDType.EtTin, "eu_oss_vat" => CustomerTaxIDType.EuOssVat, + "fo_vat" => CustomerTaxIDType.FoVat, "gb_vat" => CustomerTaxIDType.GBVat, "ge_vat" => CustomerTaxIDType.GeVat, + "gi_tin" => CustomerTaxIDType.GiTin, "gn_nif" => CustomerTaxIDType.GnNif, "hk_br" => CustomerTaxIDType.HkBr, "hr_oib" => CustomerTaxIDType.HrOib, @@ -732,6 +759,7 @@ JsonSerializerOptions options "il_vat" => CustomerTaxIDType.IlVat, "in_gst" => CustomerTaxIDType.InGst, "is_vat" => CustomerTaxIDType.IsVat, + "it_cf" => CustomerTaxIDType.ItCf, "jp_cn" => CustomerTaxIDType.JpCn, "jp_rn" => CustomerTaxIDType.JpRn, "jp_trn" => CustomerTaxIDType.JpTrn, @@ -743,6 +771,7 @@ JsonSerializerOptions options "la_tin" => CustomerTaxIDType.LaTin, "li_uid" => CustomerTaxIDType.LiUid, "li_vat" => CustomerTaxIDType.LiVat, + "lk_vat" => CustomerTaxIDType.LkVat, "ma_vat" => CustomerTaxIDType.MaVat, "md_vat" => CustomerTaxIDType.MdVat, "me_pib" => CustomerTaxIDType.MePib, @@ -760,6 +789,8 @@ JsonSerializerOptions options "om_vat" => CustomerTaxIDType.OmVat, "pe_ruc" => CustomerTaxIDType.PeRuc, "ph_tin" => CustomerTaxIDType.PhTin, + "pl_nip" => CustomerTaxIDType.PlNip, + "py_ruc" => CustomerTaxIDType.PyRuc, "ro_tin" => CustomerTaxIDType.RoTin, "rs_pib" => CustomerTaxIDType.RsPib, "ru_inn" => CustomerTaxIDType.RuInn, @@ -846,8 +877,10 @@ JsonSerializerOptions options CustomerTaxIDType.EsCif => "es_cif", CustomerTaxIDType.EtTin => "et_tin", CustomerTaxIDType.EuOssVat => "eu_oss_vat", + CustomerTaxIDType.FoVat => "fo_vat", CustomerTaxIDType.GBVat => "gb_vat", CustomerTaxIDType.GeVat => "ge_vat", + CustomerTaxIDType.GiTin => "gi_tin", CustomerTaxIDType.GnNif => "gn_nif", CustomerTaxIDType.HkBr => "hk_br", CustomerTaxIDType.HrOib => "hr_oib", @@ -856,6 +889,7 @@ JsonSerializerOptions options CustomerTaxIDType.IlVat => "il_vat", CustomerTaxIDType.InGst => "in_gst", CustomerTaxIDType.IsVat => "is_vat", + CustomerTaxIDType.ItCf => "it_cf", CustomerTaxIDType.JpCn => "jp_cn", CustomerTaxIDType.JpRn => "jp_rn", CustomerTaxIDType.JpTrn => "jp_trn", @@ -867,6 +901,7 @@ JsonSerializerOptions options CustomerTaxIDType.LaTin => "la_tin", CustomerTaxIDType.LiUid => "li_uid", CustomerTaxIDType.LiVat => "li_vat", + CustomerTaxIDType.LkVat => "lk_vat", CustomerTaxIDType.MaVat => "ma_vat", CustomerTaxIDType.MdVat => "md_vat", CustomerTaxIDType.MePib => "me_pib", @@ -884,6 +919,8 @@ JsonSerializerOptions options CustomerTaxIDType.OmVat => "om_vat", CustomerTaxIDType.PeRuc => "pe_ruc", CustomerTaxIDType.PhTin => "ph_tin", + CustomerTaxIDType.PlNip => "pl_nip", + CustomerTaxIDType.PyRuc => "py_ruc", 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..3a1ea9f0f 100644 --- a/src/Orb/Models/Customers/AccountingProviderConfig.cs +++ b/src/Orb/Models/Customers/AccountingProviderConfig.cs @@ -4,6 +4,8 @@ using System.Text.Json; using System.Text.Json.Serialization; using Orb.Core; +using Orb.Exceptions; +using System = System; namespace Orb.Models.Customers; @@ -22,12 +24,14 @@ public required string ExternalProviderID init { this._rawData.Set("external_provider_id", value); } } - public required string ProviderType + public required ApiEnum ProviderType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("provider_type"); + return this._rawData.GetNotNullClass< + ApiEnum + >("provider_type"); } init { this._rawData.Set("provider_type", value); } } @@ -36,13 +40,16 @@ public required string ProviderType public override void Validate() { _ = this.ExternalProviderID; - _ = this.ProviderType; + this.ProviderType.Validate(); } public AccountingProviderConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProviderConfig(AccountingProviderConfig accountingProviderConfig) : base(accountingProviderConfig) { } +#pragma warning restore CS8618 public AccountingProviderConfig(IReadOnlyDictionary rawData) { @@ -73,3 +80,48 @@ public AccountingProviderConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => AccountingProviderConfig.FromRawUnchecked(rawData); } + +[JsonConverter(typeof(AccountingProviderConfigProviderTypeConverter))] +public enum AccountingProviderConfigProviderType +{ + Quickbooks, + Netsuite, +} + +sealed class AccountingProviderConfigProviderTypeConverter + : JsonConverter +{ + public override AccountingProviderConfigProviderType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "quickbooks" => AccountingProviderConfigProviderType.Quickbooks, + "netsuite" => AccountingProviderConfigProviderType.Netsuite, + _ => (AccountingProviderConfigProviderType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + AccountingProviderConfigProviderType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + AccountingProviderConfigProviderType.Quickbooks => "quickbooks", + AccountingProviderConfigProviderType.Netsuite => "netsuite", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} 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..8b0acb180 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,14 +49,25 @@ 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 -/// 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. +/// creating an entry of type `decrement`. A `decrement` entry records credits as +/// usage and immediately recognizes revenue at the block's `per_unit_cost_basis`. +/// +/// For most credit removals, use `void` (no revenue impact) or `expiration_change` +/// (revenue recognized on expiration) instead. Only use `decrement` when credits +/// were genuinely consumed outside of normal event ingestion. +/// +/// 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. /// @@ -94,14 +105,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 +120,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 +139,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,29 +159,68 @@ 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) { return new System::UriBuilder( @@ -199,6 +252,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 +415,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 +438,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 +461,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 +484,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 +507,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 +529,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 +540,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 +585,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 +596,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 +675,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 +686,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 +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 } @@ -687,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 } @@ -710,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 } @@ -733,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 } @@ -756,12 +822,10 @@ JsonSerializerOptions 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 +1037,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 +1163,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 +1376,27 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// If true, the new credits purchase invoice will be marked as paid. + /// + public bool? MarkAsPaid + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mark_as_paid"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mark_as_paid", value); + } + } + /// /// An optional memo to display on the invoice. /// @@ -1324,8 +1415,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 +1457,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1373,10 +1465,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 +1569,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 +1590,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 +1610,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 +1621,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1556,7 +1651,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 +1662,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1618,10 +1713,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 +1724,20 @@ public override int GetHashCode() } 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 +1765,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 +1843,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 +1864,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 +1884,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 +1895,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1814,7 +1925,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 +1936,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1876,10 +1987,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 +1998,20 @@ public override int GetHashCode() } 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 +2039,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 +2162,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 @@ -2101,9 +2231,9 @@ public JsonElement EntryType } /// - /// A future date (specified in YYYY-MM-DD format) used for expiration change, - /// denoting when credits transferred (as part of a partial block expiration) - /// should expire. + /// A date (specified in YYYY-MM-DD format) used for expiration change, denoting + /// when credits transferred (as part of a partial block expiration) should expire. + /// This date must be on or after the effective date of the credit block. /// public required string TargetExpiryDate { @@ -2232,10 +2362,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 +2544,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 +2746,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..a0210b1b3 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,14 +49,25 @@ 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 -/// 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. +/// creating an entry of type `decrement`. A `decrement` entry records credits as +/// usage and immediately recognizes revenue at the block's `per_unit_cost_basis`. +/// +/// For most credit removals, use `void` (no revenue impact) or `expiration_change` +/// (revenue recognized on expiration) instead. Only use `decrement` when credits +/// were genuinely consumed outside of normal event ingestion. +/// +/// 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. /// @@ -94,46 +105,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,27 +151,61 @@ 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) @@ -192,6 +236,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 +384,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 +405,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 +426,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 +447,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 +468,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 +488,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 +499,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 +542,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 +553,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 +616,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 +627,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 +674,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 +691,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 +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 } @@ -669,12 +728,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 +745,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 +855,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 +947,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 +992,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 +1011,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 +1050,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 +1069,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 +1102,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 +1126,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 +1143,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 +1231,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 +1270,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 +1312,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1259,8 +1320,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 +1403,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 +1424,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 +1444,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 +1455,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1421,7 +1485,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 +1496,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1475,10 +1539,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 +1550,20 @@ public override int GetHashCode() } 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 +1590,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 +1657,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 +1678,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 +1698,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 +1709,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1657,7 +1737,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 +1748,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1709,10 +1789,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 +1800,20 @@ public override int GetHashCode() } 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 +1840,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 +1958,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) { @@ -1915,9 +2014,9 @@ public JsonElement EntryType } /// - /// A future date (specified in YYYY-MM-DD format) used for expiration change, - /// denoting when credits transferred (as part of a partial block expiration) - /// should expire. + /// A date (specified in YYYY-MM-DD format) used for expiration change, denoting + /// when credits transferred (as part of a partial block expiration) should expire. + /// This date must be on or after the effective date of the credit block. /// public required string TargetExpiryDate { @@ -2046,8 +2145,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 +2312,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 +2500,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..da98829a6 100644 --- a/src/Orb/Models/Customers/Customer.cs +++ b/src/Orb/Models/Customers/Customer.cs @@ -316,64 +316,68 @@ public required Address? ShippingAddress /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +491,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 +568,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 +613,7 @@ public enum CustomerPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerPaymentProviderConverter : JsonConverter @@ -620,6 +631,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerPaymentProvider.StripeCharge, "stripe_invoice" => CustomerPaymentProvider.StripeInvoice, "netsuite" => CustomerPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerPaymentProvider.NetsuiteAmpersand, _ => (CustomerPaymentProvider)(-1), }; } @@ -639,6 +651,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 +706,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 +776,11 @@ public override void Validate() public AccountingProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProvider(AccountingProvider accountingProvider) : base(accountingProvider) { } +#pragma warning restore CS8618 public AccountingProvider(IReadOnlyDictionary rawData) { @@ -882,8 +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..02dbffad1 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 @@ -330,64 +334,68 @@ public TaxConfiguration? TaxConfiguration /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +425,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 +459,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CustomerCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -462,6 +473,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 +526,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -499,14 +543,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 +559,7 @@ public sealed record class PaymentConfiguration : JsonModel return; } - this._rawData.Set?>( + this._rawData.Set?>( "payment_providers", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -533,8 +577,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 +613,7 @@ IReadOnlyDictionary rawData ) => PaymentConfiguration.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentProvider : JsonModel { /// @@ -584,6 +629,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 +678,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 +704,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 +717,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 +780,7 @@ public enum CustomerCreateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerCreateParamsPaymentProviderConverter @@ -737,6 +799,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerCreateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerCreateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerCreateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerCreateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerCreateParamsPaymentProvider)(-1), }; } @@ -756,6 +819,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 +922,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 +943,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 +964,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 +985,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 +1006,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 +1027,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 +1047,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 +1058,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 +1108,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 +1119,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 +1191,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 +1202,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 +1253,10 @@ JsonSerializerOptions 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 +1273,10 @@ JsonSerializerOptions 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 +1293,10 @@ JsonSerializerOptions 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 +1310,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 +1327,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 +1344,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 +1424,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 +1519,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 +1614,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..3ef7c05f6 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 { @@ -331,64 +336,68 @@ public CustomerUpdateByExternalIDParamsTaxConfiguration? TaxConfiguration /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +412,8 @@ public CustomerTaxID? TaxID public CustomerUpdateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParams( CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams ) @@ -412,6 +423,7 @@ CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams this._rawBodyData = new(customerUpdateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -429,27 +441,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 +526,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -531,10 +582,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 +655,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 +704,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 +834,7 @@ public enum CustomerUpdateByExternalIDParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateByExternalIDParamsPaymentProviderConverter @@ -779,6 +853,8 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => + CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateByExternalIDParamsPaymentProvider)(-1), }; } @@ -798,6 +874,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 +996,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 +1017,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 +1038,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 +1059,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 +1082,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 +1105,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 +1127,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 +1138,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 +1188,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 +1199,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 +1284,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 +1295,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 +1347,10 @@ JsonSerializerOptions 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 +1367,10 @@ JsonSerializerOptions 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 +1387,10 @@ JsonSerializerOptions 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 +1408,10 @@ JsonSerializerOptions 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 +1429,10 @@ JsonSerializerOptions 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 +1450,10 @@ JsonSerializerOptions 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 +1535,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 +1645,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 +1755,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..7b03cf706 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 { @@ -332,64 +338,68 @@ public CustomerUpdateParamsTaxConfiguration? TaxConfiguration /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +414,8 @@ public CustomerTaxID? TaxID public CustomerUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) : base(customerUpdateParams) { @@ -411,6 +423,7 @@ public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) this._rawBodyData = new(customerUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -428,27 +441,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 +526,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -530,10 +582,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 +649,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 +698,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 +822,7 @@ public enum CustomerUpdateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateParamsPaymentProviderConverter @@ -766,6 +841,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateParamsPaymentProvider)(-1), }; } @@ -785,6 +861,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 +982,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 +1003,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 +1024,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 +1045,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 +1068,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 +1091,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 +1113,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 +1124,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 +1174,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 +1185,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 +1270,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 +1281,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 +1333,10 @@ JsonSerializerOptions 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 +1353,10 @@ JsonSerializerOptions 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 +1373,10 @@ JsonSerializerOptions 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 +1394,10 @@ JsonSerializerOptions 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 +1415,10 @@ JsonSerializerOptions 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 +1436,10 @@ JsonSerializerOptions 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 +1521,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 +1629,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 +1737,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..d926e024b 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs @@ -10,7 +10,7 @@ namespace Orb.Models.DimensionalPriceGroups; /// /// 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 parition used +/// by a set of dimensions. Prices in a price group must specify the partition used /// to derive their usage. /// [JsonConverter(typeof(JsonModelConverter))] @@ -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..2e83d5366 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -184,64 +184,68 @@ public required IReadOnlyList CustomerBalance /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +751,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 +862,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 +992,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 +1175,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 +1410,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 +1679,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 +1848,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 +1871,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 +1894,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 +1917,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 +1938,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 +1958,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 +1969,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 +2014,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 +2025,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 +2100,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 +2111,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 +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 } @@ -2148,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 } @@ -2171,12 +2202,10 @@ JsonSerializerOptions 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 +2222,10 @@ JsonSerializerOptions 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 +2242,10 @@ JsonSerializerOptions 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 +2351,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 +2372,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 +2393,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 +2413,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 +2424,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 +2459,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 +2470,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2502,10 +2527,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 +2538,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 +2586,10 @@ JsonSerializerOptions 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 +2606,10 @@ JsonSerializerOptions 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 +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 } @@ -2731,8 +2764,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..0152fadc8 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) + ); } } @@ -180,64 +177,68 @@ public required CustomerMinified Customer /// 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 | | 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 + /// for non-Union scheme | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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 +356,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 +507,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 +746,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 +785,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 +860,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 +879,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 +987,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 +1006,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 +1038,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 +1163,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 +1182,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 +1191,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 +1214,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 +1224,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 +1263,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, @@ -1325,7 +1307,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.InvoiceSourceConverter))] +[JsonConverter(typeof(InvoiceSourceConverter))] public enum InvoiceSource { Subscription, @@ -1333,9 +1315,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 +1325,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 +1342,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 +1391,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 +1555,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 +1656,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 +1695,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 +1822,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 +1845,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 +1868,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 +1891,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 +1912,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 +1932,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 +1943,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 +1986,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 +1997,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 +2025,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 +2062,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 +2073,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 +2123,10 @@ JsonSerializerOptions 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 +2143,10 @@ JsonSerializerOptions 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 +2164,10 @@ JsonSerializerOptions 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 +2184,10 @@ JsonSerializerOptions 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 +2204,10 @@ JsonSerializerOptions 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 +2216,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 +2231,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 +2313,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 +2334,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 +2355,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 +2375,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 +2386,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 +2419,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 +2430,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2473,17 +2452,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 +2481,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 +2492,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 +2540,10 @@ JsonSerializerOptions 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 +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 } @@ -2597,12 +2580,10 @@ JsonSerializerOptions 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 +2592,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 +2607,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 +2652,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 +2718,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 +2737,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 +2770,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 +2785,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..3cfd515f9 --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs @@ -0,0 +1,1562 @@ +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 | | Faroe Islands | `fo_vat` | Faroe Islands VAT Number + /// | | 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 + /// | | Gibraltar | `gi_tin` | Gibraltar Tax Identification 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 | | Italy | `it_cf` + /// | Italian Codice Fiscale 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 | | Paraguay + /// | `py_ruc` | Paraguayan RUC 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 | | Sri Lanka | `lk_vat` | Sri Lanka 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..600a4ed4b 100644 --- a/src/Orb/Models/Invoices/InvoiceListParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListParams.cs @@ -24,8 +24,16 @@ 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. +/// +/// If you don't need line item details, minimums, maximums, or discounts, prefer +/// the [list invoices summary](/api-reference/invoice/list-invoices-summary) endpoint +/// for better performance. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking 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 +230,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 +260,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 +287,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvoiceListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -287,6 +299,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 +341,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 +388,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 +398,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 +408,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..7e25e24fc 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs @@ -184,64 +184,68 @@ public required IReadOnlyList ///
public required CustomerTaxID? CustomerTaxID @@ -628,8 +632,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 +748,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 +888,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 +1078,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 +1422,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..1151da736 100644 --- a/src/Orb/Models/Metrics/MetricFetchParams.cs +++ b/src/Orb/Models/Metrics/MetricFetchParams.cs @@ -9,20 +9,28 @@ 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. +/// 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 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 +45,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 +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/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..444c2e410 100644 --- a/src/Orb/Models/Metrics/MetricListParams.cs +++ b/src/Orb/Models/Metrics/MetricListParams.cs @@ -9,11 +9,14 @@ 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. +/// 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 MetricListParams : ParamsBase +public record class MetricListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -92,8 +95,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 +122,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static MetricListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -128,6 +134,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 +176,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..00314906c 100644 --- a/src/Orb/Models/NewAllocationPrice.cs +++ b/src/Orb/Models/NewAllocationPrice.cs @@ -116,6 +116,40 @@ 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); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(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 +186,18 @@ public override void Validate() item.Validate(); } _ = this.ItemID; + _ = this.LicenseTypeID; + _ = this.Metadata; _ = 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 +347,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..eb14a02bd 100644 --- a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs +++ b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs @@ -10,12 +10,16 @@ namespace Orb.Models.Plans.ExternalPlanID; /// -/// 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`, `description`, and +/// `metadata` of 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 @@ -25,6 +29,19 @@ public IReadOnlyDictionary RawBodyData public string? OtherExternalPlanID { get; init; } + /// + /// An optional user-defined description of the plan. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + /// /// An optional user-defined ID for this plan resource, used throughout the system /// as an alias for this Plan. Use this field to identify a plan by an existing @@ -65,6 +82,8 @@ public string? ExternalPlanID public ExternalPlanIDUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDUpdateParams(ExternalPlanIDUpdateParams externalPlanIDUpdateParams) : base(externalPlanIDUpdateParams) { @@ -72,6 +91,7 @@ public ExternalPlanIDUpdateParams(ExternalPlanIDUpdateParams externalPlanIDUpdat this._rawBodyData = new(externalPlanIDUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -89,27 +109,66 @@ 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) @@ -140,4 +199,9 @@ internal override 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..0df10391e 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs @@ -12,6 +12,9 @@ namespace Orb.Models.Plans.Migrations; [JsonConverter(typeof(JsonModelConverter))] public sealed record class MigrationCancelResponse : JsonModel { + /// + /// Unique identifier for this plan version change. + /// public required string ID { get @@ -22,6 +25,10 @@ public required string ID init { this._rawData.Set("id", value); } } + /// + /// When the migration takes effect. Can be a specific date/time, or 'end_of_term' + /// when scheduled to be at the end of the current billing period. + /// public required MigrationCancelResponseEffectiveTime? EffectiveTime { get @@ -34,6 +41,9 @@ public required MigrationCancelResponseEffectiveTime? EffectiveTime init { this._rawData.Set("effective_time", value); } } + /// + /// The ID of the plan being migrated. + /// public required string PlanID { get @@ -44,6 +54,10 @@ public required string PlanID init { this._rawData.Set("plan_id", value); } } + /// + /// Current status of the migration: 'not_started', 'in_progress', 'completed', + /// 'action_needed', or 'canceled'. + /// public required ApiEnum Status { get @@ -67,8 +81,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) { @@ -100,6 +117,10 @@ IReadOnlyDictionary rawData ) => MigrationCancelResponse.FromRawUnchecked(rawData); } +/// +/// When the migration takes effect. Can be a specific date/time, or 'end_of_term' +/// when scheduled to be at the end of the current billing period. +/// [JsonConverter(typeof(MigrationCancelResponseEffectiveTimeConverter))] public record class MigrationCancelResponseEffectiveTime : ModelBase { @@ -151,7 +172,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 +193,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 +212,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 +237,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 +248,9 @@ out ApiEnum? value /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationCancelResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -264,7 +285,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 +296,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 +365,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 +376,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 +434,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) { @@ -461,6 +499,10 @@ JsonSerializerOptions options } } +/// +/// Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', +/// or 'canceled'. +/// [JsonConverter(typeof(MigrationCancelResponseStatusConverter))] public enum MigrationCancelResponseStatus { 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..eb91c765c 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs @@ -12,6 +12,9 @@ namespace Orb.Models.Plans.Migrations; [JsonConverter(typeof(JsonModelConverter))] public sealed record class MigrationListResponse : JsonModel { + /// + /// Unique identifier for this plan version change. + /// public required string ID { get @@ -22,6 +25,10 @@ public required string ID init { this._rawData.Set("id", value); } } + /// + /// When the migration takes effect. Can be a specific date/time, or 'end_of_term' + /// when scheduled to be at the end of the current billing period. + /// public required MigrationListResponseEffectiveTime? EffectiveTime { get @@ -34,6 +41,9 @@ public required MigrationListResponseEffectiveTime? EffectiveTime init { this._rawData.Set("effective_time", value); } } + /// + /// The ID of the plan being migrated. + /// public required string PlanID { get @@ -44,6 +54,10 @@ public required string PlanID init { this._rawData.Set("plan_id", value); } } + /// + /// Current status of the migration: 'not_started', 'in_progress', 'completed', + /// 'action_needed', or 'canceled'. + /// public required ApiEnum Status { get @@ -67,8 +81,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) { @@ -100,6 +117,10 @@ IReadOnlyDictionary rawData ) => MigrationListResponse.FromRawUnchecked(rawData); } +/// +/// When the migration takes effect. Can be a specific date/time, or 'end_of_term' +/// when scheduled to be at the end of the current billing period. +/// [JsonConverter(typeof(MigrationListResponseEffectiveTimeConverter))] public record class MigrationListResponseEffectiveTime : ModelBase { @@ -151,7 +172,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 +193,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 +212,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 +237,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 +248,9 @@ out ApiEnum? value /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationListResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -264,7 +285,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 +296,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 +364,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 +375,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 +433,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) { @@ -460,6 +498,10 @@ JsonSerializerOptions options } } +/// +/// Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', +/// or 'canceled'. +/// [JsonConverter(typeof(MigrationListResponseStatusConverter))] public enum MigrationListResponseStatus { 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..76f371225 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -14,6 +14,9 @@ namespace Orb.Models.Plans.Migrations; )] public sealed record class MigrationRetrieveResponse : JsonModel { + /// + /// Unique identifier for this plan version change. + /// public required string ID { get @@ -24,6 +27,10 @@ public required string ID init { this._rawData.Set("id", value); } } + /// + /// When the migration takes effect. Can be a specific date/time, or 'end_of_term' + /// when scheduled to be at the end of the current billing period. + /// public required EffectiveTime? EffectiveTime { get @@ -34,6 +41,9 @@ public required EffectiveTime? EffectiveTime init { this._rawData.Set("effective_time", value); } } + /// + /// The ID of the plan being migrated. + /// public required string PlanID { get @@ -44,14 +54,16 @@ public required string PlanID init { this._rawData.Set("plan_id", value); } } - public required ApiEnum Status + /// + /// Current status of the migration: 'not_started', 'in_progress', 'completed', + /// 'action_needed', or 'canceled'. + /// + 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 +79,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) { @@ -100,6 +115,10 @@ IReadOnlyDictionary rawData ) => MigrationRetrieveResponse.FromRawUnchecked(rawData); } +/// +/// When the migration takes effect. Can be a specific date/time, or 'end_of_term' +/// when scheduled to be at the end of the current billing period. +/// [JsonConverter(typeof(EffectiveTimeConverter))] public record class EffectiveTime : ModelBase { @@ -145,7 +164,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 +185,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 +204,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 +226,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 +237,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 +272,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 +283,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 +335,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 +346,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 +404,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 +468,11 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Plans.Migrations.StatusConverter))] +/// +/// Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', +/// or 'canceled'. +/// +[JsonConverter(typeof(StatusConverter))] public enum Status { NotStarted, @@ -442,9 +482,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 +492,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..89522fa04 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) ); @@ -103,6 +103,19 @@ public string? DefaultInvoiceMemo init { this._rawBodyData.Set("default_invoice_memo", value); } } + /// + /// An optional user-defined description of the plan. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + public string? ExternalPlanID { get @@ -175,14 +188,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 +208,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 +242,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PlanCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -242,6 +256,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 +309,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 +332,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 +377,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,2725 +404,5669 @@ 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(JsonModelConverter))] +public sealed record class LicenseAllocationPrice : 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>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) ); } } - public string ItemID + /// + /// The pricing model type + /// + public required ApiEnum ModelType { 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.GetNotNullClass>("model_type"); } + init { this._rawData.Set("model_type", value); } } - public string Name + /// + /// The name of the price. + /// + public required 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, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); + 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 { - 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("billable_metric_id"); } + init { this._rawData.Set("billable_metric_id", value); } } + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// 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, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); } + init { this._rawData.Set("billed_in_advance", value); } } + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// 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, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } + init { this._rawData.Set("billing_cycle_configuration", value); } } + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// 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, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("conversion_rate_config"); } + init { this._rawData.Set("conversion_rate_config", value); } } + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// public string? Currency { get { - 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("currency"); } + init { this._rawData.Set("currency", value); } } + /// + /// For dimensional price: specifies a price group and dimension values + /// 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, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// An alias for the price. + /// 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, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// public double? FixedPriceQuantity { get { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } + /// + /// The property used to group this price on an invoice + /// public string? InvoiceGroupingKey { get { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } + /// + /// Within each 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.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( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string? ReferenceID + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { get { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public PricePrice(NewPlanUnitPrice value, JsonElement? element = null) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - public PricePrice(NewPlanTieredPrice 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 PricePrice(NewPlanBulkPrice 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(); + } + this.ModelType.Validate(); + _ = 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 PricePrice(global::Orb.Models.Plans.BulkWithFilters value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public LicenseAllocationPrice() { } - public PricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocationPrice(LicenseAllocationPrice licenseAllocationPrice) + : base(licenseAllocationPrice) { } +#pragma warning restore CS8618 - public PricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public PricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocationPrice(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public PricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + /// + public static LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public PricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) +class LicenseAllocationPriceFromRaw : IFromRawJson +{ + /// + public LicenseAllocationPrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseAllocationPrice.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CadenceConverter))] +public enum Cadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), + }; } - public PricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public PricePrice(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : 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 PricePrice(NewPlanPackageWithAllocationPrice 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 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( - global::Orb.Models.Plans.TieredWithProration 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 PricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public PricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public LicenseAllocation() { } - public PricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 - public PricePrice(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public PricePrice(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseAllocation(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public PricePrice( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value, - JsonElement? element = null + /// + public static LicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData ) { - 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; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public PricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class LicenseAllocationFromRaw : IFromRawJson +{ + /// + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); +} - public PricePrice(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +/// +/// The pricing model type +/// +[JsonConverter(typeof(ModelTypeConverter))] +public enum ModelType +{ + Unit, +} - public PricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null +sealed class ModelTypeConverter : JsonConverter +{ + public override ModelType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; - } - - public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unit" => ModelType.Unit, + _ => (ModelType)(-1), + }; } - public PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + ModelType value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize( + writer, + value switch + { + ModelType.Unit => "unit", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public PricePrice(global::Orb.Models.Plans.Minimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + JsonElement? _element = null; + + public JsonElement Json { - this.Value = value; - this._element = element; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - public PricePrice(global::Orb.Models.Plans.Percent value, JsonElement? element = null) + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.EventOutput value, JsonElement? element = null) + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(JsonElement 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 . + /// 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 ConversionRateConfig" + ); + } } /// - /// 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.Plans.BulkWithFilters` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Plans.BulkWithFilters? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as global::Orb.Models.Plans.BulkWithFilters; - 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 ConversionRateConfig" + ), + }; } + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); + + public static implicit operator ConversionRateConfig(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; - } - - /// - /// Returns true and sets the 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; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ConversionRateConfig" + ); + } + 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.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; - } + public virtual bool Equals(ConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanTieredPackagePrice; - 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.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; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) + int VariantIndex() { - value = this.Value as NewPlanGroupedTieredPrice; - 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.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value +sealed class ConversionRateConfigConverter : JsonConverter +{ + public override ConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - 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 ConversionRateConfig(element); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) +/// +/// 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 { - value = this.Value as NewPlanUnitWithPercentPrice; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 `global::Orb.Models.Plans.TieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Plans.TieredWithProration? value - ) + public string ItemID { - value = this.Value as global::Orb.Models.Plans.TieredWithProration; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ItemID, + newPlanTiered: (x) => x.ItemID, + newPlanBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newPlanPackage: (x) => x.ItemID, + newPlanMatrix: (x) => x.ItemID, + newPlanThresholdTotalAmount: (x) => x.ItemID, + newPlanTieredPackage: (x) => x.ItemID, + newPlanTieredWithMinimum: (x) => x.ItemID, + newPlanGroupedTiered: (x) => x.ItemID, + newPlanTieredPackageWithMinimum: (x) => x.ItemID, + newPlanPackageWithAllocation: (x) => x.ItemID, + newPlanUnitWithPercent: (x) => x.ItemID, + newPlanMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public string Name { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public double? ConversionRate { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newPlanMinimumComposite: (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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.GroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Plans.GroupedWithMinMaxThresholds? value - ) + public string? Currency { - value = this.Value as global::Orb.Models.Plans.GroupedWithMinMaxThresholds; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newPlanMinimumComposite: (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.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ExternalPriceID, + newPlanTiered: (x) => x.ExternalPriceID, + newPlanBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newPlanPackage: (x) => x.ExternalPriceID, + newPlanMatrix: (x) => x.ExternalPriceID, + newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, + newPlanTieredPackage: (x) => x.ExternalPriceID, + newPlanTieredWithMinimum: (x) => x.ExternalPriceID, + newPlanGroupedTiered: (x) => x.ExternalPriceID, + newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newPlanPackageWithAllocation: (x) => x.ExternalPriceID, + newPlanUnitWithPercent: (x) => x.ExternalPriceID, + newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoicingCycleConfiguration, + newPlanTiered: (x) => x.InvoicingCycleConfiguration, + newPlanBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newPlanPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMatrix: (x) => x.InvoicingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public string? LicenseTypeID { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } } - /// - /// Returns true and sets the 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.Plans.CumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Plans.CumulativeGroupedAllocation? value - ) + public string? ReferenceID { - value = this.Value as global::Orb.Models.Plans.CumulativeGroupedAllocation; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ReferenceID, + newPlanTiered: (x) => x.ReferenceID, + newPlanBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newPlanPackage: (x) => x.ReferenceID, + newPlanMatrix: (x) => x.ReferenceID, + newPlanThresholdTotalAmount: (x) => x.ReferenceID, + newPlanTieredPackage: (x) => x.ReferenceID, + newPlanTieredWithMinimum: (x) => x.ReferenceID, + newPlanGroupedTiered: (x) => x.ReferenceID, + newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, + newPlanPackageWithAllocation: (x) => x.ReferenceID, + newPlanUnitWithPercent: (x) => x.ReferenceID, + newPlanMatrixWithAllocation: (x) => x.ReferenceID, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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) + public PricePrice(NewPlanUnitPrice value, JsonElement? element = null) { - value = this.Value as global::Orb.Models.Plans.Minimum; - return value != 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(BulkWithFilters 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(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(DailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(MeteredAllowance 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(Percent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(EventOutput 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 . + /// 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.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - value = this.Value as NewPlanMinimumCompositePrice; + 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 . + /// 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` + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out global::Orb.Models.Plans.Percent? value) + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - value = this.Value as global::Orb.Models.Plans.Percent; + 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 . + /// 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` + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Plans.EventOutput? value - ) + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - value = this.Value as global::Orb.Models.Plans.EventOutput; + value = this.Value as NewPlanBulkPrice; return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `BulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) + { + value = this.Value as BulkWithFilters; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. /// /// /// - /// 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) => {...} - /// ); + /// if (instance.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(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 - ) + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - switch (this.Value) - { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Plans.BulkWithFilters 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.Plans.TieredWithProration 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.Plans.GroupedWithMinMaxThresholds 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.Plans.CumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Plans.Minimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Plans.Percent value: - percent(value); - break; - case global::Orb.Models.Plans.EventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException("Data did not match any variant of PricePrice"); - } + value = this.Value as NewPlanPackagePrice; + return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// + /// + /// if (instance.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. /// /// /// - /// 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) => {...} - /// ); + /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(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 + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value ) { - 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 - ), - 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"), - }; + value = this.Value as NewPlanThresholdTotalAmountPrice; + return value != null; } - 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); + /// + /// Returns true and sets the 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; + } - public static implicit operator PricePrice(global::Orb.Models.Plans.BulkWithFilters 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( - global::Orb.Models.Plans.TieredWithProration 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( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds 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( - global::Orb.Models.Plans.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator PricePrice(global::Orb.Models.Plans.Minimum value) => - new(value); - - public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); - - public static implicit operator PricePrice(global::Orb.Models.Plans.Percent value) => - new(value); - - public static implicit operator PricePrice(global::Orb.Models.Plans.EventOutput value) => - new(value); + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// Consider using or if you need to handle every variant. /// - /// - /// Thrown when the instance does not pass validation. - /// + /// + /// + /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public override void Validate() + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value + ) { - 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); + value = this.Value as NewPlanGroupedTieredPrice; + return value != null; } - public virtual bool Equals(PricePrice? other) + /// + /// Returns true and sets the 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 + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + value = this.Value as NewPlanTieredPackageWithMinimumPrice; + return value != null; } - public override int GetHashCode() + /// + /// Returns true and sets the 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 + ) { - return 0; + value = this.Value as NewPlanPackageWithAllocationPrice; + return value != null; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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; + } -sealed class PricePriceConverter : JsonConverter -{ - public override PricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; + } - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value + ) + { + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `TieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + { + value = this.Value as TieredWithProration; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 `GroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value + ) + { + value = this.Value as GroupedWithMinMaxThresholds; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 `CumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out CumulativeGroupedAllocation? value + ) + { + value = this.Value as CumulativeGroupedAllocation; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) + { + value = this.Value as MeteredAllowance; + return value != null; + } + + /// + /// Returns true and sets the 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 `Percent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) + { + value = this.Value as Percent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `EventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) + { + value = this.Value as EventOutput; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + 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 BulkWithFilters 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 MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; + case TieredWithProration 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 GroupedWithMinMaxThresholds 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 CumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case Percent value: + percent(value); + break; + case EventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of 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) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (MatrixWithThresholdDiscounts value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewPlanMinimumCompositePrice 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Func meteredAllowance, + 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), + 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), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), + TieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + Percent value => percent(value), + 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 PricePrice(NewPlanTieredPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanBulkPrice value) => new(value); + + public static implicit operator PricePrice(BulkWithFilters 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(MatrixWithThresholdDiscounts value) => new(value); + + public static implicit operator PricePrice(TieredWithProration 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(GroupedWithMinMaxThresholds 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(CumulativeGroupedAllocation value) => new(value); + + public static implicit operator PricePrice(DailyCreditAllowance value) => new(value); + + public static implicit operator PricePrice(MeteredAllowance value) => new(value); + + public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); + + public static implicit operator PricePrice(Percent value) => new(value); + + public static implicit operator PricePrice(EventOutput value) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException("Data did not match any variant of 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + MatrixWithThresholdDiscounts _ => 14, + TieredWithProration _ => 15, + NewPlanUnitWithProrationPrice _ => 16, + NewPlanGroupedAllocationPrice _ => 17, + NewPlanBulkWithProrationPrice _ => 18, + NewPlanGroupedWithProratedMinimumPrice _ => 19, + NewPlanGroupedWithMeteredMinimumPrice _ => 20, + GroupedWithMinMaxThresholds _ => 21, + NewPlanMatrixWithDisplayNamePrice _ => 22, + NewPlanGroupedTieredPackagePrice _ => 23, + NewPlanMaxGroupTieredPackagePrice _ => 24, + NewPlanScalableMatrixWithUnitPricingPrice _ => 25, + NewPlanScalableMatrixWithTieredPricingPrice _ => 26, + NewPlanCumulativeGroupedBulkPrice _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + NewPlanMinimumCompositePrice _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -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 "matrix_with_threshold_discounts": + { + 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 "daily_credit_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + 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 PricePrice(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PricePrice? 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); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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; + 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(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) { - 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": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + return new(element); + } + default: + { + return new BulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class MatrixWithThresholdDiscounts : 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); } + } + + /// + /// Configuration for matrix_with_threshold_discounts pricing + /// + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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 MatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public MatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson +{ + /// + public MatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override MatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), + }; + } - return new(element); - } - case "bulk": + public override void Write( + Utf8JsonWriter writer, + MatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} - return new(element); - } - case "bulk_with_filters": +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public MatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig + ) + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public MatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 + + public MatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixValueFromRaw : IFromRawJson +{ + /// + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } - 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 - } + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", 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 - } + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", 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 - } + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", 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 - } + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", 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 - } + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } - 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 ThresholdDiscountGroup() { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 - 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 - } + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public static ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - 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 - } +class ThresholdDiscountGroupFromRaw : IFromRawJson +{ + /// + public ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); +} - 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 - } +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - 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 - } + JsonElement? _element = null; - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public MatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public MatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - 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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public virtual bool Equals(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override int GetHashCode() + { + return 0; + } - 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 - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - 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 - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - return new(element); - } - case "minimum_composite": +sealed class MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + 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 "percent": + 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) - { - // 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 } @@ -3065,53 +6075,33 @@ JsonSerializerOptions options } default: { - return new PricePrice(element); + return new MatrixWithThresholdDiscountsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PricePrice? value, + MatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, 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 TieredWithProration : JsonModel { - /// - /// Configuration for bulk_with_filters pricing - /// - public required global::Orb.Models.Plans.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 + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } @@ -3154,7 +6144,22 @@ public required string Name this._rawData.Freeze(); return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("name", value); } + 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); } } /// @@ -3216,12 +6221,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 TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -3312,6 +6317,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -3350,19 +6368,19 @@ 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") + 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(); @@ -3374,35 +6392,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public TieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public BulkWithFilters(global::Orb.Models.Plans.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public TieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + TieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3410,61 +6432,96 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersFromRaw : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.BulkWithFilters.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.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(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence 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" => 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 + ); } +} +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : JsonModel +{ /// - /// Bulk tiers for rating based on total usage volume + /// 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>( + return this._rawData.GetNotNullStruct>( "tiers" ); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -3474,276 +6531,140 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// public override void Validate() { - foreach (var item in this.Filters) - { - item.Validate(); - } foreach (var item in this.Tiers) { item.Validate(); } } - public BulkWithFiltersConfig() { } + public TieredWithProrationConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Plans.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + public TieredWithProrationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) + TieredWithProrationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig 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 - /// - 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() { } - - public Filter(global::Orb.Models.Plans.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.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Tiers = tiers; } } -class FilterFromRaw : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Filter FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Filter.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter) )] -public sealed record class Tier : JsonModel +public sealed record class TieredWithProrationConfigTier : JsonModel { /// - /// Amount per unit + /// Inclusive tier starting value /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The lower bound for this tier + /// Amount per unit /// - public string? TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.UnitAmount; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public Tier() { } - - public Tier(global::Orb.Models.Plans.Tier tier) - : base(tier) { } - - public Tier(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } + public TieredWithProrationConfigTier() { } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this._rawData = new(rawData); } +#pragma warning disable CS8618 [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} - -class TierFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Plans.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Plans.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + TieredWithProrationConfigTier(FrozenDictionary rawData) { - 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), - }; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Cadence value, - JsonSerializerOptions options + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData ) { - 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 - ); + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -[JsonConverter(typeof(global::Orb.Models.Plans.ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -3760,19 +6681,25 @@ public JsonElement Json } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(JsonElement element) + public TieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -3781,7 +6708,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. /// /// /// @@ -3802,7 +6729,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. /// /// /// @@ -3822,7 +6749,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 +6760,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3854,7 +6781,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } } @@ -3863,7 +6790,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 +6801,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3890,16 +6817,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.ConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.ConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -3918,16 +6845,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } 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(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -3935,13 +6862,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 ConversionRateConfigConverter - : JsonConverter +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.ConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3970,12 +6910,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3992,12 +6930,10 @@ JsonSerializerOptions 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,14 +6942,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.ConversionRateConfig(element); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.ConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4022,28 +6958,40 @@ JsonSerializerOptions 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 GroupedWithMinMaxThresholds : 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 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. /// @@ -4083,21 +7031,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 +7090,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 GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4253,6 +7186,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4292,18 +7238,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -4315,35 +7261,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public TieredWithProration(global::Orb.Models.Plans.TieredWithProration tieredWithProration) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4351,19 +7301,19 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProration.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -4373,10 +7323,10 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Plans.TieredWithProrationCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4384,19 +7334,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Plans.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Plans.TieredWithProrationCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -4404,12 +7354,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Plans.TieredWithProrationCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Plans.TieredWithProrationCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Plans.TieredWithProrationCadence.Custom => "custom", + 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)) ), @@ -4420,159 +7370,102 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfig, - global::Orb.Models.Plans.TieredWithProrationConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class TieredWithProrationConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// The event property used to group before applying thresholds /// - public required IReadOnlyList Tiers + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + /// + /// The maximum amount to charge each group + /// + public required string MaximumCharge { - foreach (var item in this.Tiers) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("maximum_charge"); } + init { this._rawData.Set("maximum_charge", value); } } - public TieredWithProrationConfig() { } - - public TieredWithProrationConfig( - global::Orb.Models.Plans.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.Plans.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.Plans.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfigTier, - global::Orb.Models.Plans.TieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel -{ /// - /// Inclusive tier starting value + /// The minimum amount to charge each group, regardless of usage /// - public required string TierLowerBound + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// Amount per unit + /// 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public TieredWithProrationConfigTier() { } + public GroupedWithMinMaxThresholdsConfig() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Plans.TieredWithProrationConfigTier tieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) - : base(tieredWithProrationConfigTier) { } + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4580,17 +7473,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4607,7 +7499,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4616,7 +7508,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4625,7 +7517,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -4634,7 +7526,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 +7547,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 +7567,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 +7578,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4707,7 +7599,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -4716,7 +7608,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 +7619,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4743,16 +7635,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 GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4771,18 +7663,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 GroupedWithMinMaxThresholdsConversionRateConfig" ); } 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(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4790,13 +7680,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 GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4825,12 +7728,10 @@ JsonSerializerOptions 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 +7748,10 @@ JsonSerializerOptions 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 +7760,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -4879,44 +7776,38 @@ 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 CumulativeGroupedAllocation : 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 + /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -5017,12 +7908,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 CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5113,6 +8004,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +8056,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -5175,37 +8079,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5213,20 +8119,19 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -5236,10 +8141,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5247,19 +8152,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" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -5267,14 +8172,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", + 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)) ), @@ -5285,99 +8188,102 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public GroupedWithMinMaxThresholdsConfig() { } + public CumulativeGroupedAllocationConfig() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5385,19 +8291,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5414,7 +8317,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5423,7 +8326,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5432,7 +8335,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -5441,7 +8344,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 +8365,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 +8385,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 +8396,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5514,7 +8417,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -5523,7 +8426,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 +8437,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5550,16 +8453,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5578,18 +8481,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 CumulativeGroupedAllocationConversionRateConfig" ); } 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(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5597,13 +8498,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5632,12 +8546,10 @@ JsonSerializerOptions 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 +8566,10 @@ JsonSerializerOptions 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 +8578,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5685,45 +8593,37 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocation, - global::Orb.Models.Plans.CumulativeGroupedAllocationFromRaw - >) -)] -public sealed record class CumulativeGroupedAllocation : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : 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 - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for daily_credit_allowance pricing /// - public required global::Orb.Models.Plans.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -5824,12 +8724,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 DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5920,6 +8820,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8872,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -5982,37 +8895,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Plans.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6020,20 +8935,19 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -6043,10 +8957,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6054,19 +8967,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" => DailyCreditAllowanceCadence.Annual, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "one_time" => DailyCreditAllowanceCadence.OneTime, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -6074,14 +8987,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", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6092,57 +9003,178 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig, - global::Orb.Models.Plans.CumulativeGroupedAllocationConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// The overall allocation across all groups + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string CumulativeAllocation + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public DailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class DailyCreditAllowanceConfigFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class DailyCreditAllowanceConfigMatrixValue : JsonModel +{ /// - /// The allocation per individual group + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -6157,34 +9189,35 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public DailyCreditAllowanceConfigMatrixValue() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue ) - : base(cumulativeGroupedAllocationConfig) { } + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6192,19 +9225,17 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6221,7 +9252,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6230,7 +9261,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6239,7 +9270,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6248,7 +9279,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 +9300,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 +9320,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 +9331,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6321,7 +9352,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -6330,7 +9361,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 +9372,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6357,16 +9388,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6385,18 +9416,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 DailyCreditAllowanceConversionRateConfig" ); } 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); - } + public virtual bool Equals(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6404,13 +9433,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6439,12 +9481,10 @@ JsonSerializerOptions 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 +9501,10 @@ JsonSerializerOptions 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 +9513,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6492,23 +9528,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Minimum, - global::Orb.Models.Plans.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -6527,18 +9560,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required global::Orb.Models.Plans.MinimumConfig MinimumConfig + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -6626,12 +9659,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6722,6 +9755,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6762,8 +9808,13 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -6779,35 +9830,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public Minimum(global::Orb.Models.Plans.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Minimum FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6815,19 +9870,18 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Minimum.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -6837,9 +9891,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6847,19 +9901,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" => MeteredAllowanceCadence.Annual, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "one_time" => MeteredAllowanceCadence.OneTime, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -6867,12 +9921,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", + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6883,38 +9937,98 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.MinimumConfig, - global::Orb.Models.Plans.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -6923,61 +10037,61 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public MinimumConfig() { } + public MeteredAllowanceConfig() { } - public MinimumConfig(global::Orb.Models.Plans.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.MinimumConfig.FromRawUnchecked(rawData); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6994,7 +10108,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7003,7 +10117,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7012,7 +10126,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -7021,7 +10135,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 +10156,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 +10176,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 +10187,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7094,7 +10208,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -7103,7 +10217,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 +10228,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7130,16 +10244,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7158,16 +10272,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 MeteredAllowanceConversionRateConfig" ); } 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7175,12 +10289,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7209,12 +10337,10 @@ JsonSerializerOptions 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 +10357,10 @@ JsonSerializerOptions 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 +10369,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -7260,25 +10384,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Percent, - global::Orb.Models.Plans.PercentFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7325,14 +10442,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Plans.PercentConfig PercentConfig + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullClass("percent_config"); } init { this._rawData.Set("percent_config", value); } } @@ -7396,12 +10511,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.PercentConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7492,6 +10607,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,6 +10677,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7558,8 +10687,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Plans.Percent percent) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -7576,27 +10708,24 @@ public Percent(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Percent.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.PercentCadenceConverter))] +[JsonConverter(typeof(PercentCadenceConverter))] public enum PercentCadence { Annual, @@ -7607,9 +10736,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.PercentCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7617,19 +10746,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.PercentCadence.OneTime, - "custom" => global::Orb.Models.Plans.PercentCadence.Custom, - _ => (global::Orb.Models.Plans.PercentCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.PercentCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -7637,12 +10766,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.PercentCadence.Annual => "annual", - global::Orb.Models.Plans.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.PercentCadence.Monthly => "monthly", - global::Orb.Models.Plans.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.PercentCadence.OneTime => "one_time", - global::Orb.Models.Plans.PercentCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7655,12 +10784,7 @@ JsonSerializerOptions options /// /// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.PercentConfig, - global::Orb.Models.Plans.PercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PercentConfig : JsonModel { /// @@ -7684,8 +10808,11 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Plans.PercentConfig percentConfig) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -7700,10 +10827,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -7716,15 +10841,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7769,7 +10893,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 +10914,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 +10934,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 +10945,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7851,7 +10975,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 +10986,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7883,11 +11007,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7912,10 +11036,10 @@ public override void Validate() 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7923,13 +11047,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.Plans.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7958,12 +11094,10 @@ JsonSerializerOptions 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 +11114,10 @@ JsonSerializerOptions 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 +11126,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.PercentConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8009,25 +11141,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutput, - global::Orb.Models.Plans.EventOutputFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -8035,14 +11160,12 @@ public sealed record class EventOutput : JsonModel /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Plans.EventOutputConfig EventOutputConfig + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); + return this._rawData.GetNotNullClass("event_output_config"); } init { this._rawData.Set("event_output_config", value); } } @@ -8145,12 +11268,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8241,6 +11364,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,6 +11439,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -8312,8 +11449,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Plans.EventOutput eventOutput) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -8330,27 +11470,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutput.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -8361,10 +11498,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8372,19 +11508,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Plans.EventOutputCadence.Custom, - _ => (global::Orb.Models.Plans.EventOutputCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8392,12 +11528,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.EventOutputCadence.Annual => "annual", - global::Orb.Models.Plans.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Plans.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Plans.EventOutputCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8410,12 +11546,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutputConfig, - global::Orb.Models.Plans.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -8470,8 +11601,11 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Plans.EventOutputConfig eventOutputConfig) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -8486,8 +11620,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8502,15 +11636,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputConversionRateConfigConverter))] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8555,7 +11688,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 +11709,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 +11729,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 +11740,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8637,7 +11770,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 +11781,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8669,11 +11802,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8698,10 +11831,10 @@ public override void Validate() 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(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8709,13 +11842,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.Plans.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8744,12 +11890,10 @@ JsonSerializerOptions 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 +11910,10 @@ JsonSerializerOptions 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 +11922,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.EventOutputConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8795,7 +11937,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,8 +11975,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 +11995,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 +12008,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 +12103,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 +12124,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 +12145,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 +12166,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 +12187,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 +12207,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 +12218,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 +12263,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 +12274,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 +12341,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 +12352,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 +12402,10 @@ JsonSerializerOptions 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 +12422,10 @@ JsonSerializerOptions 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 +12442,10 @@ JsonSerializerOptions 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 +12459,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 +12476,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 +12546,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 +12567,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 +12607,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 +12617,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 +12627,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 +12646,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 +12664,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 +12681,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..925a6c0e4 100644 --- a/src/Orb/Models/Plans/PlanUpdateParams.cs +++ b/src/Orb/Models/Plans/PlanUpdateParams.cs @@ -10,12 +10,16 @@ namespace Orb.Models.Plans; /// -/// 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`, `description`, and +/// `metadata` of 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 @@ -25,6 +29,19 @@ public IReadOnlyDictionary RawBodyData public string? PlanID { get; init; } + /// + /// An optional user-defined description of the plan. + /// + public string? Description + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("description"); + } + init { this._rawBodyData.Set("description", value); } + } + /// /// An optional user-defined ID for this plan resource, used throughout the system /// as an alias for this Plan. Use this field to identify a plan by an existing @@ -65,6 +82,8 @@ public string? ExternalPlanID public PlanUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanUpdateParams(PlanUpdateParams planUpdateParams) : base(planUpdateParams) { @@ -72,6 +91,7 @@ public PlanUpdateParams(PlanUpdateParams planUpdateParams) this._rawBodyData = new(planUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public PlanUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -89,27 +109,61 @@ 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) @@ -139,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/Price.cs b/src/Orb/Models/Price.cs index 9a7e02212..cd5c9484e 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -58,6 +58,7 @@ public string ID packageWithAllocation: (x) => x.ID, unitWithPercent: (x) => x.ID, matrixWithAllocation: (x) => x.ID, + matrixWithThresholdDiscounts: (x) => x.ID, tieredWithProration: (x) => x.ID, unitWithProration: (x) => x.ID, groupedAllocation: (x) => x.ID, @@ -72,7 +73,8 @@ public string ID scalableMatrixWithTieredPricing: (x) => x.ID, cumulativeGroupedBulk: (x) => x.ID, cumulativeGroupedAllocation: (x) => x.ID, - minimum: (x) => x.ID, + dailyCreditAllowance: (x) => x.ID, + meteredAllowance: (x) => x.ID, minimumComposite: (x) => x.ID, percent: (x) => x.ID, eventOutput: (x) => x.ID @@ -99,6 +101,7 @@ public BillableMetricTiny? BillableMetric packageWithAllocation: (x) => x.BillableMetric, unitWithPercent: (x) => x.BillableMetric, matrixWithAllocation: (x) => x.BillableMetric, + matrixWithThresholdDiscounts: (x) => x.BillableMetric, tieredWithProration: (x) => x.BillableMetric, unitWithProration: (x) => x.BillableMetric, groupedAllocation: (x) => x.BillableMetric, @@ -113,7 +116,8 @@ public BillableMetricTiny? BillableMetric scalableMatrixWithTieredPricing: (x) => x.BillableMetric, cumulativeGroupedBulk: (x) => x.BillableMetric, cumulativeGroupedAllocation: (x) => x.BillableMetric, - minimum: (x) => x.BillableMetric, + dailyCreditAllowance: (x) => x.BillableMetric, + meteredAllowance: (x) => x.BillableMetric, minimumComposite: (x) => x.BillableMetric, percent: (x) => x.BillableMetric, eventOutput: (x) => x.BillableMetric @@ -140,6 +144,7 @@ public BillingCycleConfiguration BillingCycleConfiguration packageWithAllocation: (x) => x.BillingCycleConfiguration, unitWithPercent: (x) => x.BillingCycleConfiguration, matrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, tieredWithProration: (x) => x.BillingCycleConfiguration, unitWithProration: (x) => x.BillingCycleConfiguration, groupedAllocation: (x) => x.BillingCycleConfiguration, @@ -154,7 +159,8 @@ public BillingCycleConfiguration BillingCycleConfiguration scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -181,6 +187,7 @@ public double? ConversionRate packageWithAllocation: (x) => x.ConversionRate, unitWithPercent: (x) => x.ConversionRate, matrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, tieredWithProration: (x) => x.ConversionRate, unitWithProration: (x) => x.ConversionRate, groupedAllocation: (x) => x.ConversionRate, @@ -195,7 +202,8 @@ public double? ConversionRate scalableMatrixWithTieredPricing: (x) => x.ConversionRate, cumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -222,6 +230,7 @@ public double? ConversionRate packageWithAllocation: (x) => x.CreatedAt, unitWithPercent: (x) => x.CreatedAt, matrixWithAllocation: (x) => x.CreatedAt, + matrixWithThresholdDiscounts: (x) => x.CreatedAt, tieredWithProration: (x) => x.CreatedAt, unitWithProration: (x) => x.CreatedAt, groupedAllocation: (x) => x.CreatedAt, @@ -236,7 +245,8 @@ public double? ConversionRate scalableMatrixWithTieredPricing: (x) => x.CreatedAt, cumulativeGroupedBulk: (x) => x.CreatedAt, cumulativeGroupedAllocation: (x) => x.CreatedAt, - minimum: (x) => x.CreatedAt, + dailyCreditAllowance: (x) => x.CreatedAt, + meteredAllowance: (x) => x.CreatedAt, minimumComposite: (x) => x.CreatedAt, percent: (x) => x.CreatedAt, eventOutput: (x) => x.CreatedAt @@ -263,6 +273,7 @@ public Allocation? CreditAllocation packageWithAllocation: (x) => x.CreditAllocation, unitWithPercent: (x) => x.CreditAllocation, matrixWithAllocation: (x) => x.CreditAllocation, + matrixWithThresholdDiscounts: (x) => x.CreditAllocation, tieredWithProration: (x) => x.CreditAllocation, unitWithProration: (x) => x.CreditAllocation, groupedAllocation: (x) => x.CreditAllocation, @@ -277,7 +288,8 @@ public Allocation? CreditAllocation scalableMatrixWithTieredPricing: (x) => x.CreditAllocation, cumulativeGroupedBulk: (x) => x.CreditAllocation, cumulativeGroupedAllocation: (x) => x.CreditAllocation, - minimum: (x) => x.CreditAllocation, + dailyCreditAllowance: (x) => x.CreditAllocation, + meteredAllowance: (x) => x.CreditAllocation, minimumComposite: (x) => x.CreditAllocation, percent: (x) => x.CreditAllocation, eventOutput: (x) => x.CreditAllocation @@ -304,6 +316,7 @@ public string Currency packageWithAllocation: (x) => x.Currency, unitWithPercent: (x) => x.Currency, matrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, tieredWithProration: (x) => x.Currency, unitWithProration: (x) => x.Currency, groupedAllocation: (x) => x.Currency, @@ -318,7 +331,8 @@ public string Currency scalableMatrixWithTieredPricing: (x) => x.Currency, cumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -345,6 +359,7 @@ public SharedDiscount? Discount packageWithAllocation: (x) => x.Discount, unitWithPercent: (x) => x.Discount, matrixWithAllocation: (x) => x.Discount, + matrixWithThresholdDiscounts: (x) => x.Discount, tieredWithProration: (x) => x.Discount, unitWithProration: (x) => x.Discount, groupedAllocation: (x) => x.Discount, @@ -359,7 +374,8 @@ public SharedDiscount? Discount scalableMatrixWithTieredPricing: (x) => x.Discount, cumulativeGroupedBulk: (x) => x.Discount, cumulativeGroupedAllocation: (x) => x.Discount, - minimum: (x) => x.Discount, + dailyCreditAllowance: (x) => x.Discount, + meteredAllowance: (x) => x.Discount, minimumComposite: (x) => x.Discount, percent: (x) => x.Discount, eventOutput: (x) => x.Discount @@ -386,6 +402,7 @@ public string? ExternalPriceID packageWithAllocation: (x) => x.ExternalPriceID, unitWithPercent: (x) => x.ExternalPriceID, matrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, tieredWithProration: (x) => x.ExternalPriceID, unitWithProration: (x) => x.ExternalPriceID, groupedAllocation: (x) => x.ExternalPriceID, @@ -400,7 +417,8 @@ public string? ExternalPriceID scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, cumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -427,6 +445,7 @@ public double? FixedPriceQuantity packageWithAllocation: (x) => x.FixedPriceQuantity, unitWithPercent: (x) => x.FixedPriceQuantity, matrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, tieredWithProration: (x) => x.FixedPriceQuantity, unitWithProration: (x) => x.FixedPriceQuantity, groupedAllocation: (x) => x.FixedPriceQuantity, @@ -441,7 +460,8 @@ public double? FixedPriceQuantity scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -449,6 +469,49 @@ public double? 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + public BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -468,6 +531,7 @@ public BillingCycleConfiguration? InvoicingCycleConfiguration packageWithAllocation: (x) => x.InvoicingCycleConfiguration, unitWithPercent: (x) => x.InvoicingCycleConfiguration, matrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, tieredWithProration: (x) => x.InvoicingCycleConfiguration, unitWithProration: (x) => x.InvoicingCycleConfiguration, groupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -482,7 +546,8 @@ public BillingCycleConfiguration? InvoicingCycleConfiguration scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, minimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -509,6 +574,7 @@ public ItemSlim Item packageWithAllocation: (x) => x.Item, unitWithPercent: (x) => x.Item, matrixWithAllocation: (x) => x.Item, + matrixWithThresholdDiscounts: (x) => x.Item, tieredWithProration: (x) => x.Item, unitWithProration: (x) => x.Item, groupedAllocation: (x) => x.Item, @@ -523,7 +589,8 @@ public ItemSlim Item scalableMatrixWithTieredPricing: (x) => x.Item, cumulativeGroupedBulk: (x) => x.Item, cumulativeGroupedAllocation: (x) => x.Item, - minimum: (x) => x.Item, + dailyCreditAllowance: (x) => x.Item, + meteredAllowance: (x) => x.Item, minimumComposite: (x) => x.Item, percent: (x) => x.Item, eventOutput: (x) => x.Item @@ -550,6 +617,7 @@ public Maximum? Maximum packageWithAllocation: (x) => x.Maximum, unitWithPercent: (x) => x.Maximum, matrixWithAllocation: (x) => x.Maximum, + matrixWithThresholdDiscounts: (x) => x.Maximum, tieredWithProration: (x) => x.Maximum, unitWithProration: (x) => x.Maximum, groupedAllocation: (x) => x.Maximum, @@ -564,7 +632,8 @@ public Maximum? Maximum scalableMatrixWithTieredPricing: (x) => x.Maximum, cumulativeGroupedBulk: (x) => x.Maximum, cumulativeGroupedAllocation: (x) => x.Maximum, - minimum: (x) => x.Maximum, + dailyCreditAllowance: (x) => x.Maximum, + meteredAllowance: (x) => x.Maximum, minimumComposite: (x) => x.Maximum, percent: (x) => x.Maximum, eventOutput: (x) => x.Maximum @@ -591,6 +660,7 @@ public string? MaximumAmount packageWithAllocation: (x) => x.MaximumAmount, unitWithPercent: (x) => x.MaximumAmount, matrixWithAllocation: (x) => x.MaximumAmount, + matrixWithThresholdDiscounts: (x) => x.MaximumAmount, tieredWithProration: (x) => x.MaximumAmount, unitWithProration: (x) => x.MaximumAmount, groupedAllocation: (x) => x.MaximumAmount, @@ -605,7 +675,8 @@ public string? MaximumAmount scalableMatrixWithTieredPricing: (x) => x.MaximumAmount, cumulativeGroupedBulk: (x) => x.MaximumAmount, cumulativeGroupedAllocation: (x) => x.MaximumAmount, - minimum: (x) => x.MaximumAmount, + dailyCreditAllowance: (x) => x.MaximumAmount, + meteredAllowance: (x) => x.MaximumAmount, minimumComposite: (x) => x.MaximumAmount, percent: (x) => x.MaximumAmount, eventOutput: (x) => x.MaximumAmount @@ -632,6 +703,7 @@ public Minimum? Minimum packageWithAllocation: (x) => x.Minimum, unitWithPercent: (x) => x.Minimum, matrixWithAllocation: (x) => x.Minimum, + matrixWithThresholdDiscounts: (x) => x.Minimum, tieredWithProration: (x) => x.Minimum, unitWithProration: (x) => x.Minimum, groupedAllocation: (x) => x.Minimum, @@ -646,7 +718,8 @@ public Minimum? Minimum scalableMatrixWithTieredPricing: (x) => x.Minimum, cumulativeGroupedBulk: (x) => x.Minimum, cumulativeGroupedAllocation: (x) => x.Minimum, - minimum: (x) => x.Minimum, + dailyCreditAllowance: (x) => x.Minimum, + meteredAllowance: (x) => x.Minimum, minimumComposite: (x) => x.Minimum, percent: (x) => x.Minimum, eventOutput: (x) => x.Minimum @@ -673,6 +746,7 @@ public string? MinimumAmount packageWithAllocation: (x) => x.MinimumAmount, unitWithPercent: (x) => x.MinimumAmount, matrixWithAllocation: (x) => x.MinimumAmount, + matrixWithThresholdDiscounts: (x) => x.MinimumAmount, tieredWithProration: (x) => x.MinimumAmount, unitWithProration: (x) => x.MinimumAmount, groupedAllocation: (x) => x.MinimumAmount, @@ -687,7 +761,8 @@ public string? MinimumAmount scalableMatrixWithTieredPricing: (x) => x.MinimumAmount, cumulativeGroupedBulk: (x) => x.MinimumAmount, cumulativeGroupedAllocation: (x) => x.MinimumAmount, - minimum: (x) => x.MinimumAmount, + dailyCreditAllowance: (x) => x.MinimumAmount, + meteredAllowance: (x) => x.MinimumAmount, minimumComposite: (x) => x.MinimumAmount, percent: (x) => x.MinimumAmount, eventOutput: (x) => x.MinimumAmount @@ -714,6 +789,7 @@ public JsonElement ModelType packageWithAllocation: (x) => x.ModelType, unitWithPercent: (x) => x.ModelType, matrixWithAllocation: (x) => x.ModelType, + matrixWithThresholdDiscounts: (x) => x.ModelType, tieredWithProration: (x) => x.ModelType, unitWithProration: (x) => x.ModelType, groupedAllocation: (x) => x.ModelType, @@ -728,7 +804,8 @@ public JsonElement ModelType scalableMatrixWithTieredPricing: (x) => x.ModelType, cumulativeGroupedBulk: (x) => x.ModelType, cumulativeGroupedAllocation: (x) => x.ModelType, - minimum: (x) => x.ModelType, + dailyCreditAllowance: (x) => x.ModelType, + meteredAllowance: (x) => x.ModelType, minimumComposite: (x) => x.ModelType, percent: (x) => x.ModelType, eventOutput: (x) => x.ModelType @@ -755,6 +832,7 @@ public string Name packageWithAllocation: (x) => x.Name, unitWithPercent: (x) => x.Name, matrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, tieredWithProration: (x) => x.Name, unitWithProration: (x) => x.Name, groupedAllocation: (x) => x.Name, @@ -769,7 +847,8 @@ public string Name scalableMatrixWithTieredPricing: (x) => x.Name, cumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -796,6 +875,7 @@ public long? PlanPhaseOrder packageWithAllocation: (x) => x.PlanPhaseOrder, unitWithPercent: (x) => x.PlanPhaseOrder, matrixWithAllocation: (x) => x.PlanPhaseOrder, + matrixWithThresholdDiscounts: (x) => x.PlanPhaseOrder, tieredWithProration: (x) => x.PlanPhaseOrder, unitWithProration: (x) => x.PlanPhaseOrder, groupedAllocation: (x) => x.PlanPhaseOrder, @@ -810,7 +890,8 @@ public long? PlanPhaseOrder scalableMatrixWithTieredPricing: (x) => x.PlanPhaseOrder, cumulativeGroupedBulk: (x) => x.PlanPhaseOrder, cumulativeGroupedAllocation: (x) => x.PlanPhaseOrder, - minimum: (x) => x.PlanPhaseOrder, + dailyCreditAllowance: (x) => x.PlanPhaseOrder, + meteredAllowance: (x) => x.PlanPhaseOrder, minimumComposite: (x) => x.PlanPhaseOrder, percent: (x) => x.PlanPhaseOrder, eventOutput: (x) => x.PlanPhaseOrder @@ -837,6 +918,7 @@ public string? ReplacesPriceID packageWithAllocation: (x) => x.ReplacesPriceID, unitWithPercent: (x) => x.ReplacesPriceID, matrixWithAllocation: (x) => x.ReplacesPriceID, + matrixWithThresholdDiscounts: (x) => x.ReplacesPriceID, tieredWithProration: (x) => x.ReplacesPriceID, unitWithProration: (x) => x.ReplacesPriceID, groupedAllocation: (x) => x.ReplacesPriceID, @@ -851,7 +933,8 @@ public string? ReplacesPriceID scalableMatrixWithTieredPricing: (x) => x.ReplacesPriceID, cumulativeGroupedBulk: (x) => x.ReplacesPriceID, cumulativeGroupedAllocation: (x) => x.ReplacesPriceID, - minimum: (x) => x.ReplacesPriceID, + dailyCreditAllowance: (x) => x.ReplacesPriceID, + meteredAllowance: (x) => x.ReplacesPriceID, minimumComposite: (x) => x.ReplacesPriceID, percent: (x) => x.ReplacesPriceID, eventOutput: (x) => x.ReplacesPriceID @@ -878,6 +961,7 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration packageWithAllocation: (x) => x.DimensionalPriceConfiguration, unitWithPercent: (x) => x.DimensionalPriceConfiguration, matrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, tieredWithProration: (x) => x.DimensionalPriceConfiguration, unitWithProration: (x) => x.DimensionalPriceConfiguration, groupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -892,7 +976,8 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -984,6 +1069,12 @@ public Price(MatrixWithAllocation value, JsonElement? element = null) this._element = element; } + public Price(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; @@ -1068,7 +1159,13 @@ public Price(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Price(PriceMinimum value, JsonElement? element = null) + public Price(DailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(MeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1101,7 +1198,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 +1219,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 +1240,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 +1261,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 +1282,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 +1303,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 +1324,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 +1345,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 +1366,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 +1387,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 +1408,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 +1431,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 +1452,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 +1473,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. /// /// /// @@ -1393,11 +1490,34 @@ public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAlloca return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value + ) + { + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +1538,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 +1559,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 +1580,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 +1601,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 +1624,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 +1647,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 +1670,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 +1691,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 +1712,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 +1733,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 +1756,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 +1779,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 +1800,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. /// /// /// @@ -1701,22 +1821,43 @@ public bool TryPickCumulativeGroupedAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with 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.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceMinimum` + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out PriceMinimum? value) + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) { - value = this.Value as PriceMinimum; + value = this.Value as MeteredAllowance; return value != null; } @@ -1724,7 +1865,7 @@ public bool TryPickMinimum([NotNullWhen(true)] out PriceMinimum? 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. /// /// /// @@ -1745,7 +1886,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 +1907,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 +1927,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 +1938,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1848,6 +1991,7 @@ public void Switch( System::Action packageWithAllocation, System::Action unitWithPercent, System::Action matrixWithAllocation, + System::Action matrixWithThresholdDiscounts, System::Action tieredWithProration, System::Action unitWithProration, System::Action groupedAllocation, @@ -1862,7 +2006,8 @@ public void Switch( System::Action scalableMatrixWithTieredPricing, System::Action cumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action minimumComposite, System::Action percent, System::Action eventOutput @@ -1912,6 +2057,9 @@ public void Switch( case MatrixWithAllocation value: matrixWithAllocation(value); break; + case MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case TieredWithProration value: tieredWithProration(value); break; @@ -1954,8 +2102,11 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceMinimum value: - minimum(value); + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(value); break; case MinimumComposite value: minimumComposite(value); @@ -1975,7 +2126,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 +2137,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2037,6 +2190,7 @@ public T Match( System::Func packageWithAllocation, System::Func unitWithPercent, System::Func matrixWithAllocation, + System::Func matrixWithThresholdDiscounts, System::Func tieredWithProration, System::Func unitWithProration, System::Func groupedAllocation, @@ -2051,7 +2205,8 @@ public T Match( System::Func scalableMatrixWithTieredPricing, System::Func cumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func minimumComposite, System::Func percent, System::Func eventOutput @@ -2073,6 +2228,7 @@ public T Match( PackageWithAllocation value => packageWithAllocation(value), UnitWithPercent value => unitWithPercent(value), MatrixWithAllocation value => matrixWithAllocation(value), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), TieredWithProration value => tieredWithProration(value), UnitWithProration value => unitWithProration(value), GroupedAllocation value => groupedAllocation(value), @@ -2087,7 +2243,8 @@ public T Match( ScalableMatrixWithTieredPricing value => scalableMatrixWithTieredPricing(value), CumulativeGroupedBulk value => cumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceMinimum value => minimum(value), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(value), MinimumComposite value => minimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2123,6 +2280,8 @@ public T Match( public static implicit operator Price(MatrixWithAllocation value) => new(value); + public static implicit operator Price(MatrixWithThresholdDiscounts value) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); public static implicit operator Price(UnitWithProration value) => new(value); @@ -2151,7 +2310,9 @@ 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(DailyCreditAllowance value) => new(value); + + public static implicit operator Price(MeteredAllowance value) => new(value); public static implicit operator Price(MinimumComposite value) => new(value); @@ -2190,6 +2351,7 @@ public override void Validate() (packageWithAllocation) => packageWithAllocation.Validate(), (unitWithPercent) => unitWithPercent.Validate(), (matrixWithAllocation) => matrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (tieredWithProration) => tieredWithProration.Validate(), (unitWithProration) => unitWithProration.Validate(), (groupedAllocation) => groupedAllocation.Validate(), @@ -2204,17 +2366,18 @@ public override void Validate() (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +2385,52 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + 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, + MatrixWithThresholdDiscounts _ => 14, + TieredWithProration _ => 15, + UnitWithProration _ => 16, + GroupedAllocation _ => 17, + BulkWithProration _ => 18, + GroupedWithProratedMinimum _ => 19, + GroupedWithMeteredMinimum _ => 20, + GroupedWithMinMaxThresholds _ => 21, + MatrixWithDisplayName _ => 22, + GroupedTieredPackage _ => 23, + MaxGroupTieredPackage _ => 24, + ScalableMatrixWithUnitPricing _ => 25, + ScalableMatrixWithTieredPricing _ => 26, + CumulativeGroupedBulk _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + MinimumComposite _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -2253,12 +2461,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 +2478,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 +2495,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 +2515,10 @@ JsonSerializerOptions 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 +2532,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 +2549,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 +2569,10 @@ JsonSerializerOptions 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 +2586,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 +2606,10 @@ JsonSerializerOptions 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 +2623,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 +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 } @@ -2477,12 +2663,10 @@ JsonSerializerOptions 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 +2683,10 @@ JsonSerializerOptions 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 +2703,30 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -2543,12 +2743,10 @@ JsonSerializerOptions 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 +2763,10 @@ JsonSerializerOptions 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 +2783,10 @@ JsonSerializerOptions 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 +2803,10 @@ JsonSerializerOptions 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 +2823,10 @@ JsonSerializerOptions 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 +2843,10 @@ JsonSerializerOptions 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 +2863,10 @@ JsonSerializerOptions 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 +2883,10 @@ JsonSerializerOptions 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 +2903,10 @@ JsonSerializerOptions 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 +2923,10 @@ JsonSerializerOptions 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 +2943,10 @@ JsonSerializerOptions 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 +2963,10 @@ JsonSerializerOptions 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 +2983,10 @@ JsonSerializerOptions 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 +3003,50 @@ JsonSerializerOptions 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 "daily_credit_allowance": { 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 "metered_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -2870,12 +3063,10 @@ JsonSerializerOptions 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 +3080,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 +3097,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 } @@ -3089,6 +3276,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -3262,6 +3459,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() { @@ -3282,6 +3494,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -3299,6 +3512,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -3309,11 +3523,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 +3729,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 +3913,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 +3934,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 +3954,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 +3965,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3775,7 +3995,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 +4006,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3836,10 +4056,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 +4067,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +4114,10 @@ JsonSerializerOptions 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 +4134,10 @@ JsonSerializerOptions 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 +4208,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 { @@ -4137,6 +4457,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -4310,6 +4640,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() { @@ -4330,6 +4675,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -4347,6 +4693,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -4357,11 +4704,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 +4912,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 +5098,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 +5119,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 +5139,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 +5150,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4827,7 +5180,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 +5191,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4888,10 +5241,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 +5252,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5299,10 @@ JsonSerializerOptions 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 +5319,10 @@ JsonSerializerOptions 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 +5393,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 { @@ -5200,6 +5655,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -5360,6 +5825,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() { @@ -5381,6 +5861,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -5397,6 +5878,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -5407,11 +5889,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 +6097,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 +6282,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 +6303,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 +6323,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 +6334,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5876,7 +6364,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 +6375,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5937,10 +6425,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 +6436,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +6483,10 @@ JsonSerializerOptions 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 +6503,10 @@ JsonSerializerOptions 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 +6577,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 { @@ -6253,6 +6841,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -6415,6 +7013,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() { @@ -6436,6 +7049,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -6457,6 +7071,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -6467,11 +7082,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 +7233,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 +7312,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 +7391,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 +7557,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 +7745,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 +7766,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 +7786,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 +7797,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7197,7 +7827,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 +7838,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7258,10 +7888,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 +7899,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +7947,10 @@ JsonSerializerOptions 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 +7967,10 @@ JsonSerializerOptions 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 +8041,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 { @@ -7560,6 +8295,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -7733,6 +8478,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() { @@ -7753,6 +8513,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -7770,6 +8531,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -7780,11 +8542,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 +8750,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 +8936,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 +8957,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 +8977,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 +8988,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8250,7 +9018,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 +9029,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8311,10 +9079,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 +9090,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9137,10 @@ JsonSerializerOptions 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 +9157,10 @@ JsonSerializerOptions 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 +9231,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 { @@ -8612,6 +9482,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -8785,6 +9665,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() { @@ -8805,6 +9700,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.MatrixConfig.Validate(); @@ -8822,6 +9718,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -8832,11 +9729,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 +9937,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 +10123,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 +10144,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 +10164,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 +10175,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9302,7 +10205,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 +10216,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9363,10 +10266,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 +10277,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10324,10 @@ JsonSerializerOptions 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 +10344,10 @@ JsonSerializerOptions 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 +10418,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 { @@ -9666,6 +10671,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -9843,6 +10858,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() { @@ -9863,6 +10893,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -9885,6 +10916,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ThresholdTotalAmountConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -9895,11 +10927,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 +11142,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 +11333,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 +11354,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 +11374,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 +11385,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10377,7 +11415,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 +11426,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10438,10 +11476,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 +11487,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +11535,10 @@ JsonSerializerOptions 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 +11555,10 @@ JsonSerializerOptions 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 +11686,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 +11780,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 +11823,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 { @@ -10928,6 +12082,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -11105,6 +12269,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() { @@ -11125,6 +12304,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -11147,6 +12327,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -11157,11 +12338,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 +12549,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 +12737,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 +12758,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 +12778,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 +12789,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11632,7 +12819,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 +12830,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11693,10 +12880,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 +12891,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +12939,10 @@ JsonSerializerOptions 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 +12959,10 @@ JsonSerializerOptions 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 +13090,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 +13171,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 +13210,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 { @@ -12168,6 +13466,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -12345,6 +13653,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() { @@ -12365,6 +13688,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -12387,6 +13711,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -12397,11 +13722,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 +13935,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 +14124,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 +14145,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 +14165,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 +14176,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12875,7 +14206,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 +14217,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12936,10 +14267,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 +14278,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +14326,10 @@ JsonSerializerOptions 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 +14346,10 @@ JsonSerializerOptions 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 +14508,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 +14612,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 +14653,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 { @@ -13480,6 +14922,16 @@ public required GroupedTieredGroupedTieredConfig GroupedTieredConfig init { this._rawData.Set("grouped_tiered_config", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -13642,6 +15094,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() { @@ -13663,6 +15130,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedTieredConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -13684,6 +15152,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -13694,11 +15163,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 +15374,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 +15562,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 +15583,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 +15603,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 +15614,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14169,7 +15644,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 +15655,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14230,10 +15705,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 +15716,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +15764,10 @@ JsonSerializerOptions 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 +15784,10 @@ JsonSerializerOptions 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 +15868,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 +15949,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 +16035,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) )] @@ -14707,6 +16293,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -14884,6 +16480,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() { @@ -14904,6 +16517,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -14926,6 +16540,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -14936,11 +16551,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 +16767,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 +16959,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 +16980,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 +17000,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 +17011,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15420,7 +17041,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 +17052,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15481,10 +17102,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 +17113,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +17161,10 @@ JsonSerializerOptions 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 +17181,10 @@ JsonSerializerOptions 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 +17310,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 +17404,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 +17447,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 { @@ -15971,6 +17708,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -16148,6 +17895,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() { @@ -16168,6 +17930,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -16190,6 +17953,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -16200,11 +17964,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 +18179,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 +18370,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 +18391,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 +18411,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 +18422,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16682,7 +18452,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 +18463,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16743,10 +18513,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 +18524,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +18572,10 @@ JsonSerializerOptions 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 +18592,10 @@ JsonSerializerOptions 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 +18670,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 +18758,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 { @@ -17136,6 +19019,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -17313,6 +19206,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() { @@ -17333,6 +19241,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -17355,6 +19264,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithPercentConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -17365,11 +19275,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 +19486,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 +19674,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 +19695,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 +19715,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 +19726,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17840,7 +19756,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 +19767,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17901,10 +19817,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 +19828,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +19876,10 @@ JsonSerializerOptions 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 +19896,10 @@ JsonSerializerOptions 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 +20016,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 +20055,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 { @@ -18287,6 +20311,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -18464,6 +20498,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() { @@ -18484,6 +20533,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.MatrixWithAllocationConfig.Validate(); @@ -18506,6 +20556,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -18516,11 +20567,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 +20782,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 +20973,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 +20994,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 +21014,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 +21025,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18998,7 +21055,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 +21066,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19059,10 +21116,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 +21127,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +21175,10 @@ JsonSerializerOptions 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 +21195,10 @@ JsonSerializerOptions 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,8 +21269,111 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class TieredWithProration : 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< + 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 MatrixWithThresholdDiscounts : JsonModel { public required string ID { @@ -19238,42 +21407,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) ); @@ -19290,12 +21459,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required TieredWithProrationConversionRateConfig? ConversionRateConfig + public required MatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -19363,6 +21532,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -19388,6 +21567,21 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } + /// + /// Configuration for matrix_with_threshold_discounts pricing + /// + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } + } + [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -19487,14 +21681,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); } } @@ -19513,31 +21707,33 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required TieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public DimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// 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 MatrixWithThresholdDiscountsLicenseType? LicenseType { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" + return this._rawData.GetNullableClass( + "license_type" ); } - init { this._rawData.Set("dimensional_price_configuration", value); } + init { this._rawData.Set("license_type", value); } } /// @@ -19560,8 +21756,10 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); + this.MatrixWithThresholdDiscountsConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -19570,7 +21768,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { @@ -19580,32 +21778,35 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public TieredWithProration() + public MatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public TieredWithProration(TieredWithProration tieredWithProration) - : base(tieredWithProration) { } + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public TieredWithProration(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 @@ -19613,14 +21814,14 @@ public TieredWithProration(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + MatrixWithThresholdDiscounts(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProration FromRawUnchecked( + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19628,23 +21829,25 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson { /// - public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - TieredWithProration.FromRawUnchecked(rawData); + public MatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); } -[JsonConverter(typeof(TieredWithProrationBillingModeConverter))] -public enum TieredWithProrationBillingMode +[JsonConverter(typeof(MatrixWithThresholdDiscountsBillingModeConverter))] +public enum MatrixWithThresholdDiscountsBillingMode { InAdvance, InArrear, } -sealed class TieredWithProrationBillingModeConverter : JsonConverter +sealed class MatrixWithThresholdDiscountsBillingModeConverter + : JsonConverter { - public override TieredWithProrationBillingMode Read( + public override MatrixWithThresholdDiscountsBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19652,15 +21855,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => TieredWithProrationBillingMode.InAdvance, - "in_arrear" => TieredWithProrationBillingMode.InArrear, - _ => (TieredWithProrationBillingMode)(-1), + "in_advance" => MatrixWithThresholdDiscountsBillingMode.InAdvance, + "in_arrear" => MatrixWithThresholdDiscountsBillingMode.InArrear, + _ => (MatrixWithThresholdDiscountsBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationBillingMode value, + MatrixWithThresholdDiscountsBillingMode value, JsonSerializerOptions options ) { @@ -19668,8 +21871,8 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationBillingMode.InAdvance => "in_advance", - TieredWithProrationBillingMode.InArrear => "in_arrear", + MatrixWithThresholdDiscountsBillingMode.InAdvance => "in_advance", + MatrixWithThresholdDiscountsBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -19679,8 +21882,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence { OneTime, Monthly, @@ -19690,9 +21893,10 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter : JsonConverter +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override TieredWithProrationCadence Read( + public override MatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19700,19 +21904,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => TieredWithProrationCadence.OneTime, - "monthly" => TieredWithProrationCadence.Monthly, - "quarterly" => TieredWithProrationCadence.Quarterly, - "semi_annual" => TieredWithProrationCadence.SemiAnnual, - "annual" => TieredWithProrationCadence.Annual, - "custom" => TieredWithProrationCadence.Custom, - _ => (TieredWithProrationCadence)(-1), + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "annual" => MatrixWithThresholdDiscountsCadence.Annual, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCadence value, + MatrixWithThresholdDiscountsCadence value, JsonSerializerOptions options ) { @@ -19720,12 +21924,12 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCadence.OneTime => "one_time", - TieredWithProrationCadence.Monthly => "monthly", - TieredWithProrationCadence.Quarterly => "quarterly", - TieredWithProrationCadence.SemiAnnual => "semi_annual", - TieredWithProrationCadence.Annual => "annual", - TieredWithProrationCadence.Custom => "custom", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -19737,22 +21941,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - TieredWithProrationCompositePriceFilter, - TieredWithProrationCompositePriceFilterFromRaw + MatrixWithThresholdDiscountsCompositePriceFilter, + MatrixWithThresholdDiscountsCompositePriceFilterFromRaw >) )] -public sealed record class TieredWithProrationCompositePriceFilter : JsonModel +public sealed record class MatrixWithThresholdDiscountsCompositePriceFilter : 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); } @@ -19761,13 +21965,16 @@ public required ApiEnum Fi /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + MatrixWithThresholdDiscountsCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -19800,28 +22007,33 @@ public override void Validate() _ = this.Values; } - public TieredWithProrationCompositePriceFilter() { } + public MatrixWithThresholdDiscountsCompositePriceFilter() { } - public TieredWithProrationCompositePriceFilter( - TieredWithProrationCompositePriceFilter tieredWithProrationCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsCompositePriceFilter( + MatrixWithThresholdDiscountsCompositePriceFilter matrixWithThresholdDiscountsCompositePriceFilter ) - : base(tieredWithProrationCompositePriceFilter) { } + : base(matrixWithThresholdDiscountsCompositePriceFilter) { } +#pragma warning restore CS8618 - public TieredWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscountsCompositePriceFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationCompositePriceFilter(FrozenDictionary rawData) + MatrixWithThresholdDiscountsCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationCompositePriceFilter FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19829,20 +22041,20 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationCompositePriceFilterFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsCompositePriceFilterFromRaw + : IFromRawJson { /// - public TieredWithProrationCompositePriceFilter FromRawUnchecked( + public MatrixWithThresholdDiscountsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationCompositePriceFilter.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscountsCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(TieredWithProrationCompositePriceFilterFieldConverter))] -public enum TieredWithProrationCompositePriceFilterField +[JsonConverter(typeof(MatrixWithThresholdDiscountsCompositePriceFilterFieldConverter))] +public enum MatrixWithThresholdDiscountsCompositePriceFilterField { PriceID, ItemID, @@ -19851,10 +22063,10 @@ public enum TieredWithProrationCompositePriceFilterField PricingUnitID, } -sealed class TieredWithProrationCompositePriceFilterFieldConverter - : JsonConverter +sealed class MatrixWithThresholdDiscountsCompositePriceFilterFieldConverter + : JsonConverter { - public override TieredWithProrationCompositePriceFilterField Read( + public override MatrixWithThresholdDiscountsCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19862,18 +22074,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => TieredWithProrationCompositePriceFilterField.PriceID, - "item_id" => TieredWithProrationCompositePriceFilterField.ItemID, - "price_type" => TieredWithProrationCompositePriceFilterField.PriceType, - "currency" => TieredWithProrationCompositePriceFilterField.Currency, - "pricing_unit_id" => TieredWithProrationCompositePriceFilterField.PricingUnitID, - _ => (TieredWithProrationCompositePriceFilterField)(-1), + "price_id" => MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID, + "item_id" => MatrixWithThresholdDiscountsCompositePriceFilterField.ItemID, + "price_type" => MatrixWithThresholdDiscountsCompositePriceFilterField.PriceType, + "currency" => MatrixWithThresholdDiscountsCompositePriceFilterField.Currency, + "pricing_unit_id" => + MatrixWithThresholdDiscountsCompositePriceFilterField.PricingUnitID, + _ => (MatrixWithThresholdDiscountsCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCompositePriceFilterField value, + MatrixWithThresholdDiscountsCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -19881,11 +22094,12 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCompositePriceFilterField.PriceID => "price_id", - TieredWithProrationCompositePriceFilterField.ItemID => "item_id", - TieredWithProrationCompositePriceFilterField.PriceType => "price_type", - TieredWithProrationCompositePriceFilterField.Currency => "currency", - TieredWithProrationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + MatrixWithThresholdDiscountsCompositePriceFilterField.PriceID => "price_id", + MatrixWithThresholdDiscountsCompositePriceFilterField.ItemID => "item_id", + MatrixWithThresholdDiscountsCompositePriceFilterField.PriceType => "price_type", + MatrixWithThresholdDiscountsCompositePriceFilterField.Currency => "currency", + MatrixWithThresholdDiscountsCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -19898,17 +22112,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(TieredWithProrationCompositePriceFilterOperatorConverter))] -public enum TieredWithProrationCompositePriceFilterOperator +[JsonConverter(typeof(MatrixWithThresholdDiscountsCompositePriceFilterOperatorConverter))] +public enum MatrixWithThresholdDiscountsCompositePriceFilterOperator { Includes, Excludes, } -sealed class TieredWithProrationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MatrixWithThresholdDiscountsCompositePriceFilterOperatorConverter + : JsonConverter { - public override TieredWithProrationCompositePriceFilterOperator Read( + public override MatrixWithThresholdDiscountsCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19916,15 +22130,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => TieredWithProrationCompositePriceFilterOperator.Includes, - "excludes" => TieredWithProrationCompositePriceFilterOperator.Excludes, - _ => (TieredWithProrationCompositePriceFilterOperator)(-1), + "includes" => MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes, + "excludes" => MatrixWithThresholdDiscountsCompositePriceFilterOperator.Excludes, + _ => (MatrixWithThresholdDiscountsCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - TieredWithProrationCompositePriceFilterOperator value, + MatrixWithThresholdDiscountsCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -19932,8 +22146,8 @@ JsonSerializerOptions options writer, value switch { - TieredWithProrationCompositePriceFilterOperator.Includes => "includes", - TieredWithProrationCompositePriceFilterOperator.Excludes => "excludes", + MatrixWithThresholdDiscountsCompositePriceFilterOperator.Includes => "includes", + MatrixWithThresholdDiscountsCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -19943,8 +22157,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -19961,7 +22175,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -19970,7 +22184,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -19979,7 +22193,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) { this._element = element; } @@ -19988,7 +22202,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 +22223,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 +22243,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 +22254,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20061,7 +22275,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" ); } } @@ -20070,7 +22284,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 +22295,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20097,16 +22311,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 MatrixWithThresholdDiscountsConversionRateConfig" ), }; } - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator TieredWithProrationConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -20125,16 +22339,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 MatrixWithThresholdDiscountsConversionRateConfig" ); } 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(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -20142,13 +22356,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 MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter { - public override TieredWithProrationConversionRateConfig? Read( + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -20177,12 +22404,10 @@ JsonSerializerOptions 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 +22424,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20213,14 +22436,14 @@ JsonSerializerOptions options } default: { - return new TieredWithProrationConversionRateConfig(element); + return new MatrixWithThresholdDiscountsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - TieredWithProrationConversionRateConfig value, + MatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { @@ -20228,103 +22451,213 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(TieredWithProrationPriceTypeConverter))] -public enum TieredWithProrationPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class TieredWithProrationPriceTypeConverter : JsonConverter +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel { - public override TieredWithProrationPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "usage_price" => TieredWithProrationPriceType.UsagePrice, - "fixed_price" => TieredWithProrationPriceType.FixedPrice, - "composite_price" => TieredWithProrationPriceType.CompositePrice, - _ => (TieredWithProrationPriceType)(-1), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } } - public override void Write( - Utf8JsonWriter writer, - TieredWithProrationPriceType value, - JsonSerializerOptions options - ) + /// + /// First matrix dimension key. + /// + public required string FirstDimension { - JsonSerializer.Serialize( - writer, - value switch - { - TieredWithProrationPriceType.UsagePrice => "usage_price", - TieredWithProrationPriceType.FixedPrice => "fixed_price", - TieredWithProrationPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } } -} -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - TieredWithProrationTieredWithProrationConfig, - TieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class TieredWithProrationTieredWithProrationConfig : JsonModel -{ /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Per-cell unit prices. /// - public required IReadOnlyList Tiers + public required IReadOnlyList MatrixValues { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + ImmutableArray + >("matrix_values"); } init { - this._rawData.Set>( - "tiers", + this._rawData.Set>( + "matrix_values", ImmutableArray.ToImmutableArray(value) ); } } + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + /// public override void Validate() { - foreach (var item in this.Tiers) + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) { item.Validate(); } } - public TieredWithProrationTieredWithProrationConfig() { } + public MatrixWithThresholdDiscountsConfig() { } - public TieredWithProrationTieredWithProrationConfig( - TieredWithProrationTieredWithProrationConfig tieredWithProrationTieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig ) - : base(tieredWithProrationTieredWithProrationConfig) { } + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationTieredWithProrationConfig( + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithThresholdDiscountsConfigMatrixValue, + MatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class MatrixWithThresholdDiscountsConfigMatrixValue : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public MatrixWithThresholdDiscountsConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfigMatrixValue( + MatrixWithThresholdDiscountsConfigMatrixValue matrixWithThresholdDiscountsConfigMatrixValue + ) + : base(matrixWithThresholdDiscountsConfigMatrixValue) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscountsConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -20333,107 +22666,277 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationTieredWithProrationConfig(FrozenDictionary rawData) + MatrixWithThresholdDiscountsConfigMatrixValue(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} +class MatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public MatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public ThresholdDiscountGroup() { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public TieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 + + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData ) - : this() { - this.Tiers = tiers; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class ThresholdDiscountGroupFromRaw : IFromRawJson { /// - public TieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ThresholdDiscountGroup FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithThresholdDiscountsPriceTypeConverter))] +public enum MatrixWithThresholdDiscountsPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class MatrixWithThresholdDiscountsPriceTypeConverter + : JsonConverter +{ + public override MatrixWithThresholdDiscountsPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => MatrixWithThresholdDiscountsPriceType.UsagePrice, + "fixed_price" => MatrixWithThresholdDiscountsPriceType.FixedPrice, + "composite_price" => MatrixWithThresholdDiscountsPriceType.CompositePrice, + _ => (MatrixWithThresholdDiscountsPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithThresholdDiscountsPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithThresholdDiscountsPriceType.UsagePrice => "usage_price", + MatrixWithThresholdDiscountsPriceType.FixedPrice => "fixed_price", + MatrixWithThresholdDiscountsPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } } /// -/// Configuration for a single tiered with proration tier +/// 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< - TieredWithProrationTieredWithProrationConfigTier, - TieredWithProrationTieredWithProrationConfigTierFromRaw + MatrixWithThresholdDiscountsLicenseType, + MatrixWithThresholdDiscountsLicenseTypeFromRaw >) )] -public sealed record class TieredWithProrationTieredWithProrationConfigTier : JsonModel +public sealed record class MatrixWithThresholdDiscountsLicenseType : JsonModel { /// - /// Inclusive tier starting value + /// The Orb-assigned unique identifier for the license type. /// - public required string TierLowerBound + public required string ID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("id"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("id", value); } } /// - /// Amount per unit + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. /// - public required string UnitAmount + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; } - public TieredWithProrationTieredWithProrationConfigTier() { } + public MatrixWithThresholdDiscountsLicenseType() { } - public TieredWithProrationTieredWithProrationConfigTier( - TieredWithProrationTieredWithProrationConfigTier tieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsLicenseType( + MatrixWithThresholdDiscountsLicenseType matrixWithThresholdDiscountsLicenseType ) - : base(tieredWithProrationTieredWithProrationConfigTier) { } + : base(matrixWithThresholdDiscountsLicenseType) { } +#pragma warning restore CS8618 - public TieredWithProrationTieredWithProrationConfigTier( - IReadOnlyDictionary rawData - ) + public MatrixWithThresholdDiscountsLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationTieredWithProrationConfigTier(FrozenDictionary rawData) + MatrixWithThresholdDiscountsLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static TieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -20441,17 +22944,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsLicenseTypeFromRaw + : IFromRawJson { /// - public TieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public MatrixWithThresholdDiscountsLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => TieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscountsLicenseType.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class UnitWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : JsonModel { public required string ID { @@ -20485,42 +22988,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -20537,12 +23040,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required UnitWithProrationConversionRateConfig? ConversionRateConfig + public required TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -20610,6 +23113,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -20734,12 +23247,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -20761,18 +23274,18 @@ public required string? ReplacesPriceID } /// - /// Configuration for unit_with_proration pricing + /// Configuration for tiered_with_proration pricing /// - public required UnitWithProrationUnitWithProrationConfig UnitWithProrationConfig + public required TieredWithProrationTieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "unit_with_proration_config" + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" ); } - init { this._rawData.Set("unit_with_proration_config", value); } + init { this._rawData.Set("tiered_with_proration_config", value); } } public DimensionalPriceConfiguration? DimensionalPriceConfiguration @@ -20787,6 +23300,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() { @@ -20807,6 +23335,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -20817,7 +23346,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("unit_with_proration") + JsonSerializer.SerializeToElement("tiered_with_proration") ) ) { @@ -20827,32 +23356,36 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.UnitWithProrationConfig.Validate(); + this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public UnitWithProration() + public TieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + 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 UnitWithProration(UnitWithProration unitWithProration) - : base(unitWithProration) { } + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public UnitWithProration(IReadOnlyDictionary rawData) + public TieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 @@ -20860,14 +23393,14 @@ public UnitWithProration(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - UnitWithProration(FrozenDictionary rawData) + TieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnitWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -20875,23 +23408,23 @@ IReadOnlyDictionary rawData } } -class UnitWithProrationFromRaw : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public UnitWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - UnitWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } -[JsonConverter(typeof(UnitWithProrationBillingModeConverter))] -public enum UnitWithProrationBillingMode +[JsonConverter(typeof(TieredWithProrationBillingModeConverter))] +public enum TieredWithProrationBillingMode { InAdvance, InArrear, } -sealed class UnitWithProrationBillingModeConverter : JsonConverter +sealed class TieredWithProrationBillingModeConverter : JsonConverter { - public override UnitWithProrationBillingMode Read( + public override TieredWithProrationBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -20899,15 +23432,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => UnitWithProrationBillingMode.InAdvance, - "in_arrear" => UnitWithProrationBillingMode.InArrear, - _ => (UnitWithProrationBillingMode)(-1), + "in_advance" => TieredWithProrationBillingMode.InAdvance, + "in_arrear" => TieredWithProrationBillingMode.InArrear, + _ => (TieredWithProrationBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnitWithProrationBillingMode value, + TieredWithProrationBillingMode value, JsonSerializerOptions options ) { @@ -20915,8 +23448,8 @@ JsonSerializerOptions options writer, value switch { - UnitWithProrationBillingMode.InAdvance => "in_advance", - UnitWithProrationBillingMode.InArrear => "in_arrear", + TieredWithProrationBillingMode.InAdvance => "in_advance", + TieredWithProrationBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -20926,8 +23459,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnitWithProrationCadenceConverter))] -public enum UnitWithProrationCadence +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence { OneTime, Monthly, @@ -20937,9 +23470,9 @@ public enum UnitWithProrationCadence Custom, } -sealed class UnitWithProrationCadenceConverter : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override UnitWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -20947,19 +23480,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => UnitWithProrationCadence.OneTime, - "monthly" => UnitWithProrationCadence.Monthly, - "quarterly" => UnitWithProrationCadence.Quarterly, - "semi_annual" => UnitWithProrationCadence.SemiAnnual, - "annual" => UnitWithProrationCadence.Annual, - "custom" => UnitWithProrationCadence.Custom, - _ => (UnitWithProrationCadence)(-1), + "one_time" => TieredWithProrationCadence.OneTime, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "annual" => TieredWithProrationCadence.Annual, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnitWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -20967,12 +23500,12 @@ JsonSerializerOptions options writer, value switch { - UnitWithProrationCadence.OneTime => "one_time", - UnitWithProrationCadence.Monthly => "monthly", - UnitWithProrationCadence.Quarterly => "quarterly", - UnitWithProrationCadence.SemiAnnual => "semi_annual", - UnitWithProrationCadence.Annual => "annual", - UnitWithProrationCadence.Custom => "custom", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -20984,22 +23517,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - UnitWithProrationCompositePriceFilter, - UnitWithProrationCompositePriceFilterFromRaw + TieredWithProrationCompositePriceFilter, + TieredWithProrationCompositePriceFilterFromRaw >) )] -public sealed record class UnitWithProrationCompositePriceFilter : JsonModel +public sealed record class TieredWithProrationCompositePriceFilter : 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); } @@ -21008,13 +23541,13 @@ public required ApiEnum Fiel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -21047,28 +23580,31 @@ public override void Validate() _ = this.Values; } - public UnitWithProrationCompositePriceFilter() { } + public TieredWithProrationCompositePriceFilter() { } - public UnitWithProrationCompositePriceFilter( - UnitWithProrationCompositePriceFilter unitWithProrationCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationCompositePriceFilter( + TieredWithProrationCompositePriceFilter tieredWithProrationCompositePriceFilter ) - : base(unitWithProrationCompositePriceFilter) { } + : base(tieredWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 - public UnitWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) + public TieredWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - UnitWithProrationCompositePriceFilter(FrozenDictionary rawData) + TieredWithProrationCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnitWithProrationCompositePriceFilter FromRawUnchecked( + /// + public static TieredWithProrationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -21076,20 +23612,20 @@ IReadOnlyDictionary rawData } } -class UnitWithProrationCompositePriceFilterFromRaw - : IFromRawJson +class TieredWithProrationCompositePriceFilterFromRaw + : IFromRawJson { /// - public UnitWithProrationCompositePriceFilter FromRawUnchecked( + public TieredWithProrationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnitWithProrationCompositePriceFilter.FromRawUnchecked(rawData); + ) => TieredWithProrationCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(UnitWithProrationCompositePriceFilterFieldConverter))] -public enum UnitWithProrationCompositePriceFilterField +[JsonConverter(typeof(TieredWithProrationCompositePriceFilterFieldConverter))] +public enum TieredWithProrationCompositePriceFilterField { PriceID, ItemID, @@ -21098,10 +23634,10 @@ public enum UnitWithProrationCompositePriceFilterField PricingUnitID, } -sealed class UnitWithProrationCompositePriceFilterFieldConverter - : JsonConverter +sealed class TieredWithProrationCompositePriceFilterFieldConverter + : JsonConverter { - public override UnitWithProrationCompositePriceFilterField Read( + public override TieredWithProrationCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -21109,18 +23645,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => UnitWithProrationCompositePriceFilterField.PriceID, - "item_id" => UnitWithProrationCompositePriceFilterField.ItemID, - "price_type" => UnitWithProrationCompositePriceFilterField.PriceType, - "currency" => UnitWithProrationCompositePriceFilterField.Currency, - "pricing_unit_id" => UnitWithProrationCompositePriceFilterField.PricingUnitID, - _ => (UnitWithProrationCompositePriceFilterField)(-1), + "price_id" => TieredWithProrationCompositePriceFilterField.PriceID, + "item_id" => TieredWithProrationCompositePriceFilterField.ItemID, + "price_type" => TieredWithProrationCompositePriceFilterField.PriceType, + "currency" => TieredWithProrationCompositePriceFilterField.Currency, + "pricing_unit_id" => TieredWithProrationCompositePriceFilterField.PricingUnitID, + _ => (TieredWithProrationCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnitWithProrationCompositePriceFilterField value, + TieredWithProrationCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -21128,11 +23664,11 @@ JsonSerializerOptions options writer, value switch { - UnitWithProrationCompositePriceFilterField.PriceID => "price_id", - UnitWithProrationCompositePriceFilterField.ItemID => "item_id", - UnitWithProrationCompositePriceFilterField.PriceType => "price_type", - UnitWithProrationCompositePriceFilterField.Currency => "currency", - UnitWithProrationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + TieredWithProrationCompositePriceFilterField.PriceID => "price_id", + TieredWithProrationCompositePriceFilterField.ItemID => "item_id", + TieredWithProrationCompositePriceFilterField.PriceType => "price_type", + TieredWithProrationCompositePriceFilterField.Currency => "currency", + TieredWithProrationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -21145,17 +23681,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(UnitWithProrationCompositePriceFilterOperatorConverter))] -public enum UnitWithProrationCompositePriceFilterOperator +[JsonConverter(typeof(TieredWithProrationCompositePriceFilterOperatorConverter))] +public enum TieredWithProrationCompositePriceFilterOperator { Includes, Excludes, } -sealed class UnitWithProrationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class TieredWithProrationCompositePriceFilterOperatorConverter + : JsonConverter { - public override UnitWithProrationCompositePriceFilterOperator Read( + public override TieredWithProrationCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -21163,15 +23699,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => UnitWithProrationCompositePriceFilterOperator.Includes, - "excludes" => UnitWithProrationCompositePriceFilterOperator.Excludes, - _ => (UnitWithProrationCompositePriceFilterOperator)(-1), + "includes" => TieredWithProrationCompositePriceFilterOperator.Includes, + "excludes" => TieredWithProrationCompositePriceFilterOperator.Excludes, + _ => (TieredWithProrationCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnitWithProrationCompositePriceFilterOperator value, + TieredWithProrationCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -21179,8 +23715,8 @@ JsonSerializerOptions options writer, value switch { - UnitWithProrationCompositePriceFilterOperator.Includes => "includes", - UnitWithProrationCompositePriceFilterOperator.Excludes => "excludes", + TieredWithProrationCompositePriceFilterOperator.Includes => "includes", + TieredWithProrationCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -21190,8 +23726,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnitWithProrationConversionRateConfigConverter))] -public record class UnitWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -21208,7 +23744,7 @@ public JsonElement Json } } - public UnitWithProrationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -21217,7 +23753,7 @@ public UnitWithProrationConversionRateConfig( this._element = element; } - public UnitWithProrationConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -21226,7 +23762,7 @@ public UnitWithProrationConversionRateConfig( this._element = element; } - public UnitWithProrationConversionRateConfig(JsonElement element) + public TieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -21235,7 +23771,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 +23792,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 +23812,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 +23823,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21308,7 +23844,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of UnitWithProrationConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } } @@ -21317,7 +23853,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 +23864,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21344,16 +23880,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of UnitWithProrationConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ), }; } - public static implicit operator UnitWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator UnitWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -21372,16 +23908,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of UnitWithProrationConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } 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(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -21389,13 +23925,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 UnitWithProrationConversionRateConfigConverter - : JsonConverter +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override UnitWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -21424,12 +23973,10 @@ JsonSerializerOptions 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 +23993,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -21460,14 +24005,14 @@ JsonSerializerOptions options } default: { - return new UnitWithProrationConversionRateConfig(element); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - UnitWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -21475,17 +24020,17 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(UnitWithProrationPriceTypeConverter))] -public enum UnitWithProrationPriceType +[JsonConverter(typeof(TieredWithProrationPriceTypeConverter))] +public enum TieredWithProrationPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class UnitWithProrationPriceTypeConverter : JsonConverter +sealed class TieredWithProrationPriceTypeConverter : JsonConverter { - public override UnitWithProrationPriceType Read( + public override TieredWithProrationPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -21493,16 +24038,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => UnitWithProrationPriceType.UsagePrice, - "fixed_price" => UnitWithProrationPriceType.FixedPrice, - "composite_price" => UnitWithProrationPriceType.CompositePrice, - _ => (UnitWithProrationPriceType)(-1), + "usage_price" => TieredWithProrationPriceType.UsagePrice, + "fixed_price" => TieredWithProrationPriceType.FixedPrice, + "composite_price" => TieredWithProrationPriceType.CompositePrice, + _ => (TieredWithProrationPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - UnitWithProrationPriceType value, + TieredWithProrationPriceType value, JsonSerializerOptions options ) { @@ -21510,9 +24055,9 @@ JsonSerializerOptions options writer, value switch { - UnitWithProrationPriceType.UsagePrice => "usage_price", - UnitWithProrationPriceType.FixedPrice => "fixed_price", - UnitWithProrationPriceType.CompositePrice => "composite_price", + TieredWithProrationPriceType.UsagePrice => "usage_price", + TieredWithProrationPriceType.FixedPrice => "fixed_price", + TieredWithProrationPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -21523,18 +24068,125 @@ JsonSerializerOptions options } /// -/// Configuration for unit_with_proration pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - UnitWithProrationUnitWithProrationConfig, - UnitWithProrationUnitWithProrationConfigFromRaw + TieredWithProrationTieredWithProrationConfig, + TieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class UnitWithProrationUnitWithProrationConfig : JsonModel +public sealed record class TieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// Rate per unit of usage + /// 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>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationTieredWithProrationConfig( + TieredWithProrationTieredWithProrationConfig tieredWithProrationTieredWithProrationConfig + ) + : base(tieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationTieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public TieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationTieredWithProrationConfigTier, + TieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class TieredWithProrationTieredWithProrationConfigTier : 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 { @@ -21549,17 +24201,21 @@ public required string UnitAmount /// public override void Validate() { + _ = this.TierLowerBound; _ = this.UnitAmount; } - public UnitWithProrationUnitWithProrationConfig() { } + public TieredWithProrationTieredWithProrationConfigTier() { } - public UnitWithProrationUnitWithProrationConfig( - UnitWithProrationUnitWithProrationConfig unitWithProrationUnitWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationTieredWithProrationConfigTier( + TieredWithProrationTieredWithProrationConfigTier tieredWithProrationTieredWithProrationConfigTier ) - : base(unitWithProrationUnitWithProrationConfig) { } + : base(tieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public UnitWithProrationUnitWithProrationConfig( + public TieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -21568,39 +24224,133 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - UnitWithProrationUnitWithProrationConfig(FrozenDictionary rawData) + TieredWithProrationTieredWithProrationConfigTier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static UnitWithProrationUnitWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class TieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public TieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + 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 UnitWithProrationUnitWithProrationConfig(string unitAmount) - : this() + public TieredWithProrationLicenseType( + TieredWithProrationLicenseType tieredWithProrationLicenseType + ) + : base(tieredWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseType(IReadOnlyDictionary rawData) { - this.UnitAmount = unitAmount; + 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 UnitWithProrationUnitWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationLicenseTypeFromRaw : IFromRawJson { /// - public UnitWithProrationUnitWithProrationConfig FromRawUnchecked( + public TieredWithProrationLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => UnitWithProrationUnitWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationLicenseType.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class GroupedAllocation : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UnitWithProration : JsonModel { public required string ID { @@ -21634,42 +24384,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -21686,12 +24436,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedAllocationConversionRateConfig? ConversionRateConfig + public required UnitWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -21759,19 +24509,14 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } - /// - /// Configuration for grouped_allocation pricing - /// - public required GroupedAllocationGroupedAllocationConfig GroupedAllocationConfig + public required string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_allocation_config" - ); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("grouped_allocation_config", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } public required BillingCycleConfiguration? InvoicingCycleConfiguration @@ -21898,12 +24643,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -21924,6 +24669,21 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } + /// + /// Configuration for unit_with_proration pricing + /// + public required UnitWithProrationUnitWithProrationConfig UnitWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "unit_with_proration_config" + ); + } + init { this._rawData.Set("unit_with_proration_config", value); } + } + public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get @@ -21936,6 +24696,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() { @@ -21956,7 +24731,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedAllocationConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -21967,7 +24742,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_allocation") + JsonSerializer.SerializeToElement("unit_with_proration") ) ) { @@ -21977,31 +24752,36 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; + this.UnitWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedAllocation() + public UnitWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + 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 GroupedAllocation(GroupedAllocation groupedAllocation) - : base(groupedAllocation) { } + public UnitWithProration(UnitWithProration unitWithProration) + : base(unitWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedAllocation(IReadOnlyDictionary rawData) + public UnitWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); } #pragma warning disable CS8618 @@ -22009,14 +24789,14 @@ public GroupedAllocation(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedAllocation(FrozenDictionary rawData) + UnitWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedAllocation FromRawUnchecked( + /// + public static UnitWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -22024,23 +24804,23 @@ IReadOnlyDictionary rawData } } -class GroupedAllocationFromRaw : IFromRawJson +class UnitWithProrationFromRaw : IFromRawJson { /// - public GroupedAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => - GroupedAllocation.FromRawUnchecked(rawData); + public UnitWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitWithProration.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedAllocationBillingModeConverter))] -public enum GroupedAllocationBillingMode +[JsonConverter(typeof(UnitWithProrationBillingModeConverter))] +public enum UnitWithProrationBillingMode { InAdvance, InArrear, } -sealed class GroupedAllocationBillingModeConverter : JsonConverter +sealed class UnitWithProrationBillingModeConverter : JsonConverter { - public override GroupedAllocationBillingMode Read( + public override UnitWithProrationBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -22048,15 +24828,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedAllocationBillingMode.InAdvance, - "in_arrear" => GroupedAllocationBillingMode.InArrear, - _ => (GroupedAllocationBillingMode)(-1), + "in_advance" => UnitWithProrationBillingMode.InAdvance, + "in_arrear" => UnitWithProrationBillingMode.InArrear, + _ => (UnitWithProrationBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedAllocationBillingMode value, + UnitWithProrationBillingMode value, JsonSerializerOptions options ) { @@ -22064,8 +24844,8 @@ JsonSerializerOptions options writer, value switch { - GroupedAllocationBillingMode.InAdvance => "in_advance", - GroupedAllocationBillingMode.InArrear => "in_arrear", + UnitWithProrationBillingMode.InAdvance => "in_advance", + UnitWithProrationBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -22075,8 +24855,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedAllocationCadenceConverter))] -public enum GroupedAllocationCadence +[JsonConverter(typeof(UnitWithProrationCadenceConverter))] +public enum UnitWithProrationCadence { OneTime, Monthly, @@ -22086,9 +24866,9 @@ public enum GroupedAllocationCadence Custom, } -sealed class GroupedAllocationCadenceConverter : JsonConverter +sealed class UnitWithProrationCadenceConverter : JsonConverter { - public override GroupedAllocationCadence Read( + public override UnitWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -22096,19 +24876,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedAllocationCadence.OneTime, - "monthly" => GroupedAllocationCadence.Monthly, - "quarterly" => GroupedAllocationCadence.Quarterly, - "semi_annual" => GroupedAllocationCadence.SemiAnnual, - "annual" => GroupedAllocationCadence.Annual, - "custom" => GroupedAllocationCadence.Custom, - _ => (GroupedAllocationCadence)(-1), + "one_time" => UnitWithProrationCadence.OneTime, + "monthly" => UnitWithProrationCadence.Monthly, + "quarterly" => UnitWithProrationCadence.Quarterly, + "semi_annual" => UnitWithProrationCadence.SemiAnnual, + "annual" => UnitWithProrationCadence.Annual, + "custom" => UnitWithProrationCadence.Custom, + _ => (UnitWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedAllocationCadence value, + UnitWithProrationCadence value, JsonSerializerOptions options ) { @@ -22116,12 +24896,12 @@ JsonSerializerOptions options writer, value switch { - GroupedAllocationCadence.OneTime => "one_time", - GroupedAllocationCadence.Monthly => "monthly", - GroupedAllocationCadence.Quarterly => "quarterly", - GroupedAllocationCadence.SemiAnnual => "semi_annual", - GroupedAllocationCadence.Annual => "annual", - GroupedAllocationCadence.Custom => "custom", + UnitWithProrationCadence.OneTime => "one_time", + UnitWithProrationCadence.Monthly => "monthly", + UnitWithProrationCadence.Quarterly => "quarterly", + UnitWithProrationCadence.SemiAnnual => "semi_annual", + UnitWithProrationCadence.Annual => "annual", + UnitWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -22133,22 +24913,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedAllocationCompositePriceFilter, - GroupedAllocationCompositePriceFilterFromRaw + UnitWithProrationCompositePriceFilter, + UnitWithProrationCompositePriceFilterFromRaw >) )] -public sealed record class GroupedAllocationCompositePriceFilter : JsonModel +public sealed record class UnitWithProrationCompositePriceFilter : 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); } @@ -22157,13 +24937,13 @@ public required ApiEnum Fiel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -22196,28 +24976,31 @@ public override void Validate() _ = this.Values; } - public GroupedAllocationCompositePriceFilter() { } + public UnitWithProrationCompositePriceFilter() { } - public GroupedAllocationCompositePriceFilter( - GroupedAllocationCompositePriceFilter groupedAllocationCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationCompositePriceFilter( + UnitWithProrationCompositePriceFilter unitWithProrationCompositePriceFilter ) - : base(groupedAllocationCompositePriceFilter) { } + : base(unitWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 - public GroupedAllocationCompositePriceFilter(IReadOnlyDictionary rawData) + public UnitWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedAllocationCompositePriceFilter(FrozenDictionary rawData) + UnitWithProrationCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedAllocationCompositePriceFilter FromRawUnchecked( + /// + public static UnitWithProrationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -22225,20 +25008,20 @@ IReadOnlyDictionary rawData } } -class GroupedAllocationCompositePriceFilterFromRaw - : IFromRawJson +class UnitWithProrationCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedAllocationCompositePriceFilter FromRawUnchecked( + public UnitWithProrationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); + ) => UnitWithProrationCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedAllocationCompositePriceFilterFieldConverter))] -public enum GroupedAllocationCompositePriceFilterField +[JsonConverter(typeof(UnitWithProrationCompositePriceFilterFieldConverter))] +public enum UnitWithProrationCompositePriceFilterField { PriceID, ItemID, @@ -22247,10 +25030,10 @@ public enum GroupedAllocationCompositePriceFilterField PricingUnitID, } -sealed class GroupedAllocationCompositePriceFilterFieldConverter - : JsonConverter +sealed class UnitWithProrationCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedAllocationCompositePriceFilterField Read( + public override UnitWithProrationCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -22258,18 +25041,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => GroupedAllocationCompositePriceFilterField.PriceID, - "item_id" => GroupedAllocationCompositePriceFilterField.ItemID, - "price_type" => GroupedAllocationCompositePriceFilterField.PriceType, - "currency" => GroupedAllocationCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedAllocationCompositePriceFilterField.PricingUnitID, - _ => (GroupedAllocationCompositePriceFilterField)(-1), + "price_id" => UnitWithProrationCompositePriceFilterField.PriceID, + "item_id" => UnitWithProrationCompositePriceFilterField.ItemID, + "price_type" => UnitWithProrationCompositePriceFilterField.PriceType, + "currency" => UnitWithProrationCompositePriceFilterField.Currency, + "pricing_unit_id" => UnitWithProrationCompositePriceFilterField.PricingUnitID, + _ => (UnitWithProrationCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedAllocationCompositePriceFilterField value, + UnitWithProrationCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -22277,11 +25060,11 @@ JsonSerializerOptions options writer, value switch { - GroupedAllocationCompositePriceFilterField.PriceID => "price_id", - GroupedAllocationCompositePriceFilterField.ItemID => "item_id", - GroupedAllocationCompositePriceFilterField.PriceType => "price_type", - GroupedAllocationCompositePriceFilterField.Currency => "currency", - GroupedAllocationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + UnitWithProrationCompositePriceFilterField.PriceID => "price_id", + UnitWithProrationCompositePriceFilterField.ItemID => "item_id", + UnitWithProrationCompositePriceFilterField.PriceType => "price_type", + UnitWithProrationCompositePriceFilterField.Currency => "currency", + UnitWithProrationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -22294,17 +25077,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedAllocationCompositePriceFilterOperatorConverter))] -public enum GroupedAllocationCompositePriceFilterOperator +[JsonConverter(typeof(UnitWithProrationCompositePriceFilterOperatorConverter))] +public enum UnitWithProrationCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedAllocationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class UnitWithProrationCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedAllocationCompositePriceFilterOperator Read( + public override UnitWithProrationCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -22312,15 +25095,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedAllocationCompositePriceFilterOperator.Includes, - "excludes" => GroupedAllocationCompositePriceFilterOperator.Excludes, - _ => (GroupedAllocationCompositePriceFilterOperator)(-1), + "includes" => UnitWithProrationCompositePriceFilterOperator.Includes, + "excludes" => UnitWithProrationCompositePriceFilterOperator.Excludes, + _ => (UnitWithProrationCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedAllocationCompositePriceFilterOperator value, + UnitWithProrationCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -22328,8 +25111,8 @@ JsonSerializerOptions options writer, value switch { - GroupedAllocationCompositePriceFilterOperator.Includes => "includes", - GroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", + UnitWithProrationCompositePriceFilterOperator.Includes => "includes", + UnitWithProrationCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -22339,8 +25122,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedAllocationConversionRateConfigConverter))] -public record class GroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(UnitWithProrationConversionRateConfigConverter))] +public record class UnitWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -22357,7 +25140,7 @@ public JsonElement Json } } - public GroupedAllocationConversionRateConfig( + public UnitWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -22366,7 +25149,7 @@ public GroupedAllocationConversionRateConfig( this._element = element; } - public GroupedAllocationConversionRateConfig( + public UnitWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -22375,7 +25158,7 @@ public GroupedAllocationConversionRateConfig( this._element = element; } - public GroupedAllocationConversionRateConfig(JsonElement element) + public UnitWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -22384,7 +25167,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 +25188,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 +25208,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 +25219,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22457,7 +25240,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedAllocationConversionRateConfig" + "Data did not match any variant of UnitWithProrationConversionRateConfig" ); } } @@ -22466,7 +25249,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 +25260,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22493,16 +25276,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedAllocationConversionRateConfig" + "Data did not match any variant of UnitWithProrationConversionRateConfig" ), }; } - public static implicit operator GroupedAllocationConversionRateConfig( + public static implicit operator UnitWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedAllocationConversionRateConfig( + public static implicit operator UnitWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -22521,16 +25304,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedAllocationConversionRateConfig" + "Data did not match any variant of UnitWithProrationConversionRateConfig" ); } 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(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -22538,13 +25321,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 GroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class UnitWithProrationConversionRateConfigConverter + : JsonConverter { - public override GroupedAllocationConversionRateConfig? Read( + public override UnitWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -22573,12 +25369,10 @@ JsonSerializerOptions 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 +25389,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -22609,14 +25401,14 @@ JsonSerializerOptions options } default: { - return new GroupedAllocationConversionRateConfig(element); + return new UnitWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedAllocationConversionRateConfig value, + UnitWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -22624,32 +25416,159 @@ JsonSerializerOptions options } } +[JsonConverter(typeof(UnitWithProrationPriceTypeConverter))] +public enum UnitWithProrationPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class UnitWithProrationPriceTypeConverter : JsonConverter +{ + public override UnitWithProrationPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => UnitWithProrationPriceType.UsagePrice, + "fixed_price" => UnitWithProrationPriceType.FixedPrice, + "composite_price" => UnitWithProrationPriceType.CompositePrice, + _ => (UnitWithProrationPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + UnitWithProrationPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + UnitWithProrationPriceType.UsagePrice => "usage_price", + UnitWithProrationPriceType.FixedPrice => "fixed_price", + UnitWithProrationPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + /// -/// Configuration for grouped_allocation pricing +/// Configuration for unit_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedAllocationGroupedAllocationConfig, - GroupedAllocationGroupedAllocationConfigFromRaw + UnitWithProrationUnitWithProrationConfig, + UnitWithProrationUnitWithProrationConfigFromRaw >) )] -public sealed record class GroupedAllocationGroupedAllocationConfig : JsonModel +public sealed record class UnitWithProrationUnitWithProrationConfig : JsonModel { /// - /// Usage allocation per group + /// Rate per unit of usage /// - public required string Allocation + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("allocation"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("allocation", value); } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.UnitAmount; + } + + public UnitWithProrationUnitWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationUnitWithProrationConfig( + UnitWithProrationUnitWithProrationConfig unitWithProrationUnitWithProrationConfig + ) + : base(unitWithProrationUnitWithProrationConfig) { } +#pragma warning restore CS8618 + + public UnitWithProrationUnitWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationUnitWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationUnitWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UnitWithProrationUnitWithProrationConfig(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class UnitWithProrationUnitWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public UnitWithProrationUnitWithProrationConfig FromRawUnchecked( + 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); } } /// - /// How to determine the groups that should each be allocated some quantity + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. /// public required string GroupingKey { @@ -22662,50 +25581,49 @@ public required string GroupingKey } /// - /// Unit rate for post-allocation + /// The name of the license type. /// - public required string OverageUnitRate + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("overage_unit_rate"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("overage_unit_rate", value); } + init { this._rawData.Set("name", value); } } /// public override void Validate() { - _ = this.Allocation; + _ = this.ID; _ = this.GroupingKey; - _ = this.OverageUnitRate; + _ = this.Name; } - public GroupedAllocationGroupedAllocationConfig() { } + public UnitWithProrationLicenseType() { } - public GroupedAllocationGroupedAllocationConfig( - GroupedAllocationGroupedAllocationConfig groupedAllocationGroupedAllocationConfig - ) - : base(groupedAllocationGroupedAllocationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseType(UnitWithProrationLicenseType unitWithProrationLicenseType) + : base(unitWithProrationLicenseType) { } +#pragma warning restore CS8618 - public GroupedAllocationGroupedAllocationConfig( - IReadOnlyDictionary rawData - ) + public UnitWithProrationLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedAllocationGroupedAllocationConfig(FrozenDictionary rawData) + UnitWithProrationLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedAllocationGroupedAllocationConfig FromRawUnchecked( + /// + public static UnitWithProrationLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -22713,64 +25631,16 @@ IReadOnlyDictionary rawData } } -class GroupedAllocationGroupedAllocationConfigFromRaw - : IFromRawJson +class UnitWithProrationLicenseTypeFromRaw : IFromRawJson { /// - public GroupedAllocationGroupedAllocationConfig FromRawUnchecked( + public UnitWithProrationLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedAllocationGroupedAllocationConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(GroupedAllocationPriceTypeConverter))] -public enum GroupedAllocationPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class GroupedAllocationPriceTypeConverter : JsonConverter -{ - public override GroupedAllocationPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => GroupedAllocationPriceType.UsagePrice, - "fixed_price" => GroupedAllocationPriceType.FixedPrice, - "composite_price" => GroupedAllocationPriceType.CompositePrice, - _ => (GroupedAllocationPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedAllocationPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedAllocationPriceType.UsagePrice => "usage_price", - GroupedAllocationPriceType.FixedPrice => "fixed_price", - GroupedAllocationPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => UnitWithProrationLicenseType.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class BulkWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedAllocation : JsonModel { public required string ID { @@ -22804,57 +25674,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - /// - /// Configuration for bulk_with_proration pricing - /// - public required BulkWithProrationBulkWithProrationConfig BulkWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_proration_config" - ); - } - init { this._rawData.Set("bulk_with_proration_config", value); } - } - - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -22871,12 +25726,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required BulkWithProrationConversionRateConfig? ConversionRateConfig + public required GroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -22944,6 +25799,31 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + /// + /// Configuration for grouped_allocation pricing + /// + public required GroupedAllocationGroupedAllocationConfig GroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_allocation_config" + ); + } + init { this._rawData.Set("grouped_allocation_config", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -23068,12 +25948,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -23106,6 +25986,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() { @@ -23113,7 +26008,6 @@ public override void Validate() this.BillableMetric?.Validate(); this.BillingCycleConfiguration.Validate(); this.BillingMode.Validate(); - this.BulkWithProrationConfig.Validate(); this.Cadence.Validate(); foreach (var item in this.CompositePriceFilters ?? []) { @@ -23127,6 +26021,8 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + this.GroupedAllocationConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -23137,7 +26033,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_proration") + JsonSerializer.SerializeToElement("grouped_allocation") ) ) { @@ -23148,30 +26044,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 BulkWithProration() + public GroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + 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 BulkWithProration(BulkWithProration bulkWithProration) - : base(bulkWithProration) { } + public GroupedAllocation(GroupedAllocation groupedAllocation) + : base(groupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public BulkWithProration(IReadOnlyDictionary rawData) + public GroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); } #pragma warning disable CS8618 @@ -23179,14 +26079,14 @@ public BulkWithProration(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - BulkWithProration(FrozenDictionary rawData) + GroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithProration FromRawUnchecked( + /// + public static GroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -23194,23 +26094,23 @@ IReadOnlyDictionary rawData } } -class BulkWithProrationFromRaw : IFromRawJson +class GroupedAllocationFromRaw : IFromRawJson { /// - public BulkWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => - BulkWithProration.FromRawUnchecked(rawData); + public GroupedAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(BulkWithProrationBillingModeConverter))] -public enum BulkWithProrationBillingMode +[JsonConverter(typeof(GroupedAllocationBillingModeConverter))] +public enum GroupedAllocationBillingMode { InAdvance, InArrear, } -sealed class BulkWithProrationBillingModeConverter : JsonConverter +sealed class GroupedAllocationBillingModeConverter : JsonConverter { - public override BulkWithProrationBillingMode Read( + public override GroupedAllocationBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23218,15 +26118,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => BulkWithProrationBillingMode.InAdvance, - "in_arrear" => BulkWithProrationBillingMode.InArrear, - _ => (BulkWithProrationBillingMode)(-1), + "in_advance" => GroupedAllocationBillingMode.InAdvance, + "in_arrear" => GroupedAllocationBillingMode.InArrear, + _ => (GroupedAllocationBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - BulkWithProrationBillingMode value, + GroupedAllocationBillingMode value, JsonSerializerOptions options ) { @@ -23234,8 +26134,64 @@ JsonSerializerOptions options writer, value switch { - BulkWithProrationBillingMode.InAdvance => "in_advance", - BulkWithProrationBillingMode.InArrear => "in_arrear", + GroupedAllocationBillingMode.InAdvance => "in_advance", + GroupedAllocationBillingMode.InArrear => "in_arrear", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(GroupedAllocationCadenceConverter))] +public enum GroupedAllocationCadence +{ + OneTime, + Monthly, + Quarterly, + SemiAnnual, + Annual, + Custom, +} + +sealed class GroupedAllocationCadenceConverter : JsonConverter +{ + public override GroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "one_time" => GroupedAllocationCadence.OneTime, + "monthly" => GroupedAllocationCadence.Monthly, + "quarterly" => GroupedAllocationCadence.Quarterly, + "semi_annual" => GroupedAllocationCadence.SemiAnnual, + "annual" => GroupedAllocationCadence.Annual, + "custom" => GroupedAllocationCadence.Custom, + _ => (GroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCadence.OneTime => "one_time", + GroupedAllocationCadence.Monthly => "monthly", + GroupedAllocationCadence.Quarterly => "quarterly", + GroupedAllocationCadence.SemiAnnual => "semi_annual", + GroupedAllocationCadence.Annual => "annual", + GroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -23245,33 +26201,58 @@ JsonSerializerOptions options } } -/// -/// Configuration for bulk_with_proration pricing -/// [JsonConverter( typeof(JsonModelConverter< - BulkWithProrationBulkWithProrationConfig, - BulkWithProrationBulkWithProrationConfigFromRaw + GroupedAllocationCompositePriceFilter, + GroupedAllocationCompositePriceFilterFromRaw >) )] -public sealed record class BulkWithProrationBulkWithProrationConfig : JsonModel +public sealed record class GroupedAllocationCompositePriceFilter : JsonModel { /// - /// Bulk tiers for rating based on total usage volume + /// The property of the price to filter on. /// - public required IReadOnlyList Tiers + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + 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 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>( - "tiers", + this._rawData.Set>( + "values", ImmutableArray.ToImmutableArray(value) ); } @@ -23280,154 +26261,2606 @@ public required IReadOnlyList Tier /// public override void Validate() { - foreach (var item in this.Tiers) - { - item.Validate(); - } + this.Field.Validate(); + this.Operator.Validate(); + _ = this.Values; } - public BulkWithProrationBulkWithProrationConfig() { } + public GroupedAllocationCompositePriceFilter() { } - public BulkWithProrationBulkWithProrationConfig( - BulkWithProrationBulkWithProrationConfig bulkWithProrationBulkWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationCompositePriceFilter( + GroupedAllocationCompositePriceFilter groupedAllocationCompositePriceFilter ) - : base(bulkWithProrationBulkWithProrationConfig) { } + : base(groupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 - public BulkWithProrationBulkWithProrationConfig( - IReadOnlyDictionary rawData - ) + public GroupedAllocationCompositePriceFilter(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithProrationBulkWithProrationConfig(FrozenDictionary rawData) + GroupedAllocationCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithProrationBulkWithProrationConfig FromRawUnchecked( + /// + public static GroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public BulkWithProrationBulkWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class BulkWithProrationBulkWithProrationConfigFromRaw - : IFromRawJson +class GroupedAllocationCompositePriceFilterFromRaw + : IFromRawJson { /// - public BulkWithProrationBulkWithProrationConfig FromRawUnchecked( + public GroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => BulkWithProrationBulkWithProrationConfig.FromRawUnchecked(rawData); + ) => GroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier with proration +/// The property of the price to filter on. /// -[JsonConverter( - typeof(JsonModelConverter< - BulkWithProrationBulkWithProrationConfigTier, - BulkWithProrationBulkWithProrationConfigTierFromRaw - >) -)] -public sealed record class BulkWithProrationBulkWithProrationConfigTier : JsonModel +[JsonConverter(typeof(GroupedAllocationCompositePriceFilterFieldConverter))] +public enum GroupedAllocationCompositePriceFilterField { - /// - /// Cost per unit - /// - public required string UnitAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class GroupedAllocationCompositePriceFilterFieldConverter + : JsonConverter +{ + public override GroupedAllocationCompositePriceFilterField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "price_id" => GroupedAllocationCompositePriceFilterField.PriceID, + "item_id" => GroupedAllocationCompositePriceFilterField.ItemID, + "price_type" => GroupedAllocationCompositePriceFilterField.PriceType, + "currency" => GroupedAllocationCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedAllocationCompositePriceFilterField.PricingUnitID, + _ => (GroupedAllocationCompositePriceFilterField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCompositePriceFilterField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCompositePriceFilterField.PriceID => "price_id", + GroupedAllocationCompositePriceFilterField.ItemID => "item_id", + GroupedAllocationCompositePriceFilterField.PriceType => "price_type", + GroupedAllocationCompositePriceFilterField.Currency => "currency", + GroupedAllocationCompositePriceFilterField.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(GroupedAllocationCompositePriceFilterOperatorConverter))] +public enum GroupedAllocationCompositePriceFilterOperator +{ + Includes, + Excludes, +} + +sealed class GroupedAllocationCompositePriceFilterOperatorConverter + : JsonConverter +{ + public override GroupedAllocationCompositePriceFilterOperator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => GroupedAllocationCompositePriceFilterOperator.Includes, + "excludes" => GroupedAllocationCompositePriceFilterOperator.Excludes, + _ => (GroupedAllocationCompositePriceFilterOperator)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationCompositePriceFilterOperator value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationCompositePriceFilterOperator.Includes => "includes", + GroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[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); + } +} + +/// +/// Configuration for grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedAllocationGroupedAllocationConfig, + GroupedAllocationGroupedAllocationConfigFromRaw + >) +)] +public sealed record class GroupedAllocationGroupedAllocationConfig : 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 GroupedAllocationGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationGroupedAllocationConfig( + GroupedAllocationGroupedAllocationConfig groupedAllocationGroupedAllocationConfig + ) + : base(groupedAllocationGroupedAllocationConfig) { } +#pragma warning restore CS8618 + + public GroupedAllocationGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationGroupedAllocationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationGroupedAllocationConfigFromRaw + : IFromRawJson +{ + /// + public GroupedAllocationGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedAllocationPriceTypeConverter))] +public enum GroupedAllocationPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class GroupedAllocationPriceTypeConverter : JsonConverter +{ + public override GroupedAllocationPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => GroupedAllocationPriceType.UsagePrice, + "fixed_price" => GroupedAllocationPriceType.FixedPrice, + "composite_price" => GroupedAllocationPriceType.CompositePrice, + _ => (GroupedAllocationPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedAllocationPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedAllocationPriceType.UsagePrice => "usage_price", + GroupedAllocationPriceType.FixedPrice => "fixed_price", + GroupedAllocationPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + 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 +{ + 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>( + "billing_mode" + ); + } + init { this._rawData.Set("billing_mode", value); } + } + + /// + /// Configuration for bulk_with_proration pricing + /// + public required BulkWithProrationBulkWithProrationConfig BulkWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_proration_config" + ); + } + init { this._rawData.Set("bulk_with_proration_config", value); } + } + + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "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 BulkWithProrationConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Allocation? CreditAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("credit_allocation"); + } + init { this._rawData.Set("credit_allocation", value); } + } + + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + [System::Obsolete("deprecated")] + public required SharedDiscount? Discount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("discount"); + } + init { this._rawData.Set("discount", value); } + } + + public required string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + public required double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", 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>( + "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); } + } + + /// + /// 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() + { + _ = this.ID; + this.BillableMetric?.Validate(); + this.BillingCycleConfiguration.Validate(); + this.BillingMode.Validate(); + this.BulkWithProrationConfig.Validate(); + this.Cadence.Validate(); + foreach (var item in this.CompositePriceFilters ?? []) + { + item.Validate(); + } + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.CreatedAt; + this.CreditAllocation?.Validate(); + _ = this.Currency; + this.Discount?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + 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("bulk_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.PlanPhaseOrder; + 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 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" + )] + public BulkWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); + } + +#pragma warning disable CS8618 + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] + [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); +} + +[JsonConverter(typeof(BulkWithProrationBillingModeConverter))] +public enum BulkWithProrationBillingMode +{ + InAdvance, + InArrear, +} + +sealed class BulkWithProrationBillingModeConverter : JsonConverter +{ + public override BulkWithProrationBillingMode Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "in_advance" => BulkWithProrationBillingMode.InAdvance, + "in_arrear" => BulkWithProrationBillingMode.InArrear, + _ => (BulkWithProrationBillingMode)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationBillingMode value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationBillingMode.InAdvance => "in_advance", + BulkWithProrationBillingMode.InArrear => "in_arrear", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for bulk_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationBulkWithProrationConfig, + BulkWithProrationBulkWithProrationConfigFromRaw + >) +)] +public sealed record class BulkWithProrationBulkWithProrationConfig : 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>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public BulkWithProrationBulkWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationBulkWithProrationConfig( + BulkWithProrationBulkWithProrationConfig bulkWithProrationBulkWithProrationConfig + ) + : base(bulkWithProrationBulkWithProrationConfig) { } +#pragma warning restore CS8618 + + public BulkWithProrationBulkWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationBulkWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationBulkWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class BulkWithProrationBulkWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public BulkWithProrationBulkWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationBulkWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier with proration +/// +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationBulkWithProrationConfigTier, + BulkWithProrationBulkWithProrationConfigTierFromRaw + >) +)] +public sealed record class BulkWithProrationBulkWithProrationConfigTier : 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 BulkWithProrationBulkWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationBulkWithProrationConfigTier( + BulkWithProrationBulkWithProrationConfigTier bulkWithProrationBulkWithProrationConfigTier + ) + : base(bulkWithProrationBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public BulkWithProrationBulkWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationBulkWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BulkWithProrationBulkWithProrationConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class BulkWithProrationBulkWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public BulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationBulkWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(BulkWithProrationCadenceConverter))] +public enum BulkWithProrationCadence +{ + OneTime, + Monthly, + Quarterly, + SemiAnnual, + Annual, + Custom, +} + +sealed class BulkWithProrationCadenceConverter : JsonConverter +{ + public override BulkWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "one_time" => BulkWithProrationCadence.OneTime, + "monthly" => BulkWithProrationCadence.Monthly, + "quarterly" => BulkWithProrationCadence.Quarterly, + "semi_annual" => BulkWithProrationCadence.SemiAnnual, + "annual" => BulkWithProrationCadence.Annual, + "custom" => BulkWithProrationCadence.Custom, + _ => (BulkWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCadence.OneTime => "one_time", + BulkWithProrationCadence.Monthly => "monthly", + BulkWithProrationCadence.Quarterly => "quarterly", + BulkWithProrationCadence.SemiAnnual => "semi_annual", + BulkWithProrationCadence.Annual => "annual", + BulkWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + BulkWithProrationCompositePriceFilter, + BulkWithProrationCompositePriceFilterFromRaw + >) +)] +public sealed record class BulkWithProrationCompositePriceFilter : 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 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 BulkWithProrationCompositePriceFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationCompositePriceFilter( + BulkWithProrationCompositePriceFilter bulkWithProrationCompositePriceFilter + ) + : base(bulkWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 + + public BulkWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationCompositePriceFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationCompositePriceFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationCompositePriceFilterFromRaw + : IFromRawJson +{ + /// + public BulkWithProrationCompositePriceFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationCompositePriceFilter.FromRawUnchecked(rawData); +} + +/// +/// The property of the price to filter on. +/// +[JsonConverter(typeof(BulkWithProrationCompositePriceFilterFieldConverter))] +public enum BulkWithProrationCompositePriceFilterField +{ + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class BulkWithProrationCompositePriceFilterFieldConverter + : JsonConverter +{ + public override BulkWithProrationCompositePriceFilterField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "price_id" => BulkWithProrationCompositePriceFilterField.PriceID, + "item_id" => BulkWithProrationCompositePriceFilterField.ItemID, + "price_type" => BulkWithProrationCompositePriceFilterField.PriceType, + "currency" => BulkWithProrationCompositePriceFilterField.Currency, + "pricing_unit_id" => BulkWithProrationCompositePriceFilterField.PricingUnitID, + _ => (BulkWithProrationCompositePriceFilterField)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCompositePriceFilterField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCompositePriceFilterField.PriceID => "price_id", + BulkWithProrationCompositePriceFilterField.ItemID => "item_id", + BulkWithProrationCompositePriceFilterField.PriceType => "price_type", + BulkWithProrationCompositePriceFilterField.Currency => "currency", + BulkWithProrationCompositePriceFilterField.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(BulkWithProrationCompositePriceFilterOperatorConverter))] +public enum BulkWithProrationCompositePriceFilterOperator +{ + Includes, + Excludes, +} + +sealed class BulkWithProrationCompositePriceFilterOperatorConverter + : JsonConverter +{ + public override BulkWithProrationCompositePriceFilterOperator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => BulkWithProrationCompositePriceFilterOperator.Includes, + "excludes" => BulkWithProrationCompositePriceFilterOperator.Excludes, + _ => (BulkWithProrationCompositePriceFilterOperator)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationCompositePriceFilterOperator value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationCompositePriceFilterOperator.Includes => "includes", + BulkWithProrationCompositePriceFilterOperator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[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(BulkWithProrationPriceTypeConverter))] +public enum BulkWithProrationPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class BulkWithProrationPriceTypeConverter : JsonConverter +{ + public override BulkWithProrationPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => BulkWithProrationPriceType.UsagePrice, + "fixed_price" => BulkWithProrationPriceType.FixedPrice, + "composite_price" => BulkWithProrationPriceType.CompositePrice, + _ => (BulkWithProrationPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithProrationPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BulkWithProrationPriceType.UsagePrice => "usage_price", + BulkWithProrationPriceType.FixedPrice => "fixed_price", + BulkWithProrationPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + 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) +)] +public sealed record class GroupedWithProratedMinimum : 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 GroupedWithProratedMinimumConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required Allocation? CreditAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("credit_allocation"); + } + init { this._rawData.Set("credit_allocation", value); } + } + + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("unit_amount", value); } + 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); } } /// - /// The lower bound for this tier + /// Configuration for grouped_with_prorated_minimum pricing /// - public string? TierLowerBound + public required GroupedWithProratedMinimumGroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass( + "grouped_with_prorated_minimum_config" + ); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("grouped_with_prorated_minimum_config", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", 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); } + } + + /// + /// 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() { - _ = this.UnitAmount; - _ = this.TierLowerBound; + _ = this.ID; + this.BillableMetric?.Validate(); + this.BillingCycleConfiguration.Validate(); + this.BillingMode.Validate(); + this.Cadence.Validate(); + foreach (var item in this.CompositePriceFilters ?? []) + { + item.Validate(); + } + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.CreatedAt; + this.CreditAllocation?.Validate(); + _ = this.Currency; + this.Discount?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + this.GroupedWithProratedMinimumConfig.Validate(); + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + this.Item.Validate(); + this.Maximum?.Validate(); + _ = this.MaximumAmount; + _ = this.Metadata; + this.Minimum?.Validate(); + _ = this.MinimumAmount; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.PlanPhaseOrder; + this.PriceType.Validate(); + _ = this.ReplacesPriceID; + this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } - public BulkWithProrationBulkWithProrationConfigTier() { } + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] + public GroupedWithProratedMinimum() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + } - public BulkWithProrationBulkWithProrationConfigTier( - BulkWithProrationBulkWithProrationConfigTier bulkWithProrationBulkWithProrationConfigTier - ) - : base(bulkWithProrationBulkWithProrationConfigTier) { } +#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 - public BulkWithProrationBulkWithProrationConfigTier( - IReadOnlyDictionary rawData - ) + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] + public GroupedWithProratedMinimum(IReadOnlyDictionary rawData) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); } #pragma warning disable CS8618 + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] [SetsRequiredMembers] - BulkWithProrationBulkWithProrationConfigTier(FrozenDictionary rawData) + GroupedWithProratedMinimum(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + /// + public static GroupedWithProratedMinimum FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public BulkWithProrationBulkWithProrationConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class BulkWithProrationBulkWithProrationConfigTierFromRaw - : IFromRawJson +class GroupedWithProratedMinimumFromRaw : IFromRawJson { /// - public BulkWithProrationBulkWithProrationConfigTier FromRawUnchecked( + public GroupedWithProratedMinimum FromRawUnchecked( IReadOnlyDictionary rawData - ) => BulkWithProrationBulkWithProrationConfigTier.FromRawUnchecked(rawData); + ) => GroupedWithProratedMinimum.FromRawUnchecked(rawData); } -[JsonConverter(typeof(BulkWithProrationCadenceConverter))] -public enum BulkWithProrationCadence +[JsonConverter(typeof(GroupedWithProratedMinimumBillingModeConverter))] +public enum GroupedWithProratedMinimumBillingMode +{ + InAdvance, + InArrear, +} + +sealed class GroupedWithProratedMinimumBillingModeConverter + : JsonConverter +{ + public override GroupedWithProratedMinimumBillingMode Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "in_advance" => GroupedWithProratedMinimumBillingMode.InAdvance, + "in_arrear" => GroupedWithProratedMinimumBillingMode.InArrear, + _ => (GroupedWithProratedMinimumBillingMode)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithProratedMinimumBillingMode value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithProratedMinimumBillingMode.InAdvance => "in_advance", + GroupedWithProratedMinimumBillingMode.InArrear => "in_arrear", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(GroupedWithProratedMinimumCadenceConverter))] +public enum GroupedWithProratedMinimumCadence { OneTime, Monthly, @@ -23437,9 +28870,10 @@ public enum BulkWithProrationCadence Custom, } -sealed class BulkWithProrationCadenceConverter : JsonConverter +sealed class GroupedWithProratedMinimumCadenceConverter + : JsonConverter { - public override BulkWithProrationCadence Read( + public override GroupedWithProratedMinimumCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23447,19 +28881,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => BulkWithProrationCadence.OneTime, - "monthly" => BulkWithProrationCadence.Monthly, - "quarterly" => BulkWithProrationCadence.Quarterly, - "semi_annual" => BulkWithProrationCadence.SemiAnnual, - "annual" => BulkWithProrationCadence.Annual, - "custom" => BulkWithProrationCadence.Custom, - _ => (BulkWithProrationCadence)(-1), + "one_time" => GroupedWithProratedMinimumCadence.OneTime, + "monthly" => GroupedWithProratedMinimumCadence.Monthly, + "quarterly" => GroupedWithProratedMinimumCadence.Quarterly, + "semi_annual" => GroupedWithProratedMinimumCadence.SemiAnnual, + "annual" => GroupedWithProratedMinimumCadence.Annual, + "custom" => GroupedWithProratedMinimumCadence.Custom, + _ => (GroupedWithProratedMinimumCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - BulkWithProrationCadence value, + GroupedWithProratedMinimumCadence value, JsonSerializerOptions options ) { @@ -23467,12 +28901,12 @@ JsonSerializerOptions options writer, value switch { - BulkWithProrationCadence.OneTime => "one_time", - BulkWithProrationCadence.Monthly => "monthly", - BulkWithProrationCadence.Quarterly => "quarterly", - BulkWithProrationCadence.SemiAnnual => "semi_annual", - BulkWithProrationCadence.Annual => "annual", - BulkWithProrationCadence.Custom => "custom", + GroupedWithProratedMinimumCadence.OneTime => "one_time", + GroupedWithProratedMinimumCadence.Monthly => "monthly", + GroupedWithProratedMinimumCadence.Quarterly => "quarterly", + GroupedWithProratedMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithProratedMinimumCadence.Annual => "annual", + GroupedWithProratedMinimumCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -23484,22 +28918,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - BulkWithProrationCompositePriceFilter, - BulkWithProrationCompositePriceFilterFromRaw + GroupedWithProratedMinimumCompositePriceFilter, + GroupedWithProratedMinimumCompositePriceFilterFromRaw >) )] -public sealed record class BulkWithProrationCompositePriceFilter : JsonModel +public sealed record class GroupedWithProratedMinimumCompositePriceFilter : 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); } @@ -23508,13 +28942,13 @@ public required ApiEnum Fiel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -23547,28 +28981,33 @@ public override void Validate() _ = this.Values; } - public BulkWithProrationCompositePriceFilter() { } + public GroupedWithProratedMinimumCompositePriceFilter() { } - public BulkWithProrationCompositePriceFilter( - BulkWithProrationCompositePriceFilter bulkWithProrationCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumCompositePriceFilter( + GroupedWithProratedMinimumCompositePriceFilter groupedWithProratedMinimumCompositePriceFilter ) - : base(bulkWithProrationCompositePriceFilter) { } + : base(groupedWithProratedMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 - public BulkWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) + public GroupedWithProratedMinimumCompositePriceFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithProrationCompositePriceFilter(FrozenDictionary rawData) + GroupedWithProratedMinimumCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static BulkWithProrationCompositePriceFilter FromRawUnchecked( + /// + public static GroupedWithProratedMinimumCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -23576,20 +29015,20 @@ IReadOnlyDictionary rawData } } -class BulkWithProrationCompositePriceFilterFromRaw - : IFromRawJson +class GroupedWithProratedMinimumCompositePriceFilterFromRaw + : IFromRawJson { /// - public BulkWithProrationCompositePriceFilter FromRawUnchecked( + public GroupedWithProratedMinimumCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => BulkWithProrationCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedWithProratedMinimumCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(BulkWithProrationCompositePriceFilterFieldConverter))] -public enum BulkWithProrationCompositePriceFilterField +[JsonConverter(typeof(GroupedWithProratedMinimumCompositePriceFilterFieldConverter))] +public enum GroupedWithProratedMinimumCompositePriceFilterField { PriceID, ItemID, @@ -23598,10 +29037,10 @@ public enum BulkWithProrationCompositePriceFilterField PricingUnitID, } -sealed class BulkWithProrationCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedWithProratedMinimumCompositePriceFilterFieldConverter + : JsonConverter { - public override BulkWithProrationCompositePriceFilterField Read( + public override GroupedWithProratedMinimumCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23609,18 +29048,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => BulkWithProrationCompositePriceFilterField.PriceID, - "item_id" => BulkWithProrationCompositePriceFilterField.ItemID, - "price_type" => BulkWithProrationCompositePriceFilterField.PriceType, - "currency" => BulkWithProrationCompositePriceFilterField.Currency, - "pricing_unit_id" => BulkWithProrationCompositePriceFilterField.PricingUnitID, - _ => (BulkWithProrationCompositePriceFilterField)(-1), + "price_id" => GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + "item_id" => GroupedWithProratedMinimumCompositePriceFilterField.ItemID, + "price_type" => GroupedWithProratedMinimumCompositePriceFilterField.PriceType, + "currency" => GroupedWithProratedMinimumCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID, + _ => (GroupedWithProratedMinimumCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - BulkWithProrationCompositePriceFilterField value, + GroupedWithProratedMinimumCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -23628,11 +29067,12 @@ JsonSerializerOptions options writer, value switch { - BulkWithProrationCompositePriceFilterField.PriceID => "price_id", - BulkWithProrationCompositePriceFilterField.ItemID => "item_id", - BulkWithProrationCompositePriceFilterField.PriceType => "price_type", - BulkWithProrationCompositePriceFilterField.Currency => "currency", - BulkWithProrationCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + GroupedWithProratedMinimumCompositePriceFilterField.PriceID => "price_id", + GroupedWithProratedMinimumCompositePriceFilterField.ItemID => "item_id", + GroupedWithProratedMinimumCompositePriceFilterField.PriceType => "price_type", + GroupedWithProratedMinimumCompositePriceFilterField.Currency => "currency", + GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -23645,17 +29085,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(BulkWithProrationCompositePriceFilterOperatorConverter))] -public enum BulkWithProrationCompositePriceFilterOperator +[JsonConverter(typeof(GroupedWithProratedMinimumCompositePriceFilterOperatorConverter))] +public enum GroupedWithProratedMinimumCompositePriceFilterOperator { Includes, Excludes, } -sealed class BulkWithProrationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedWithProratedMinimumCompositePriceFilterOperatorConverter + : JsonConverter { - public override BulkWithProrationCompositePriceFilterOperator Read( + public override GroupedWithProratedMinimumCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23663,15 +29103,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => BulkWithProrationCompositePriceFilterOperator.Includes, - "excludes" => BulkWithProrationCompositePriceFilterOperator.Excludes, - _ => (BulkWithProrationCompositePriceFilterOperator)(-1), + "includes" => GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + "excludes" => GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes, + _ => (GroupedWithProratedMinimumCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - BulkWithProrationCompositePriceFilterOperator value, + GroupedWithProratedMinimumCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -23679,8 +29119,8 @@ JsonSerializerOptions options writer, value switch { - BulkWithProrationCompositePriceFilterOperator.Includes => "includes", - BulkWithProrationCompositePriceFilterOperator.Excludes => "excludes", + GroupedWithProratedMinimumCompositePriceFilterOperator.Includes => "includes", + GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -23690,8 +29130,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(BulkWithProrationConversionRateConfigConverter))] -public record class BulkWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithProratedMinimumConversionRateConfigConverter))] +public record class GroupedWithProratedMinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -23708,7 +29148,7 @@ public JsonElement Json } } - public BulkWithProrationConversionRateConfig( + public GroupedWithProratedMinimumConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -23717,7 +29157,7 @@ public BulkWithProrationConversionRateConfig( this._element = element; } - public BulkWithProrationConversionRateConfig( + public GroupedWithProratedMinimumConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -23726,7 +29166,7 @@ public BulkWithProrationConversionRateConfig( this._element = element; } - public BulkWithProrationConversionRateConfig(JsonElement element) + public GroupedWithProratedMinimumConversionRateConfig(JsonElement element) { this._element = element; } @@ -23735,7 +29175,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 +29196,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 +29216,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 +29227,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23808,7 +29248,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of BulkWithProrationConversionRateConfig" + "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" ); } } @@ -23817,7 +29257,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 +29268,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23844,16 +29284,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of BulkWithProrationConversionRateConfig" + "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" ), }; } - public static implicit operator BulkWithProrationConversionRateConfig( + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator BulkWithProrationConversionRateConfig( + public static implicit operator GroupedWithProratedMinimumConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -23872,16 +29312,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of BulkWithProrationConversionRateConfig" + "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" ); } 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(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -23889,13 +29329,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 BulkWithProrationConversionRateConfigConverter - : JsonConverter +sealed class GroupedWithProratedMinimumConversionRateConfigConverter + : JsonConverter { - public override BulkWithProrationConversionRateConfig? Read( + public override GroupedWithProratedMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23924,12 +29377,10 @@ JsonSerializerOptions 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 +29397,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -23960,14 +29409,14 @@ JsonSerializerOptions options } default: { - return new BulkWithProrationConversionRateConfig(element); + return new GroupedWithProratedMinimumConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - BulkWithProrationConversionRateConfig value, + GroupedWithProratedMinimumConversionRateConfig value, JsonSerializerOptions options ) { @@ -23975,17 +29424,121 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(BulkWithProrationPriceTypeConverter))] -public enum BulkWithProrationPriceType +/// +/// Configuration for grouped_with_prorated_minimum pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumGroupedWithProratedMinimumConfig : 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 GroupedWithProratedMinimumGroupedWithProratedMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig groupedWithProratedMinimumGroupedWithProratedMinimumConfig + ) + : base(groupedWithProratedMinimumGroupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumGroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(GroupedWithProratedMinimumPriceTypeConverter))] +public enum GroupedWithProratedMinimumPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class BulkWithProrationPriceTypeConverter : JsonConverter +sealed class GroupedWithProratedMinimumPriceTypeConverter + : JsonConverter { - public override BulkWithProrationPriceType Read( + public override GroupedWithProratedMinimumPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -23993,16 +29546,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => BulkWithProrationPriceType.UsagePrice, - "fixed_price" => BulkWithProrationPriceType.FixedPrice, - "composite_price" => BulkWithProrationPriceType.CompositePrice, - _ => (BulkWithProrationPriceType)(-1), + "usage_price" => GroupedWithProratedMinimumPriceType.UsagePrice, + "fixed_price" => GroupedWithProratedMinimumPriceType.FixedPrice, + "composite_price" => GroupedWithProratedMinimumPriceType.CompositePrice, + _ => (GroupedWithProratedMinimumPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - BulkWithProrationPriceType value, + GroupedWithProratedMinimumPriceType value, JsonSerializerOptions options ) { @@ -24010,9 +29563,9 @@ JsonSerializerOptions options writer, value switch { - BulkWithProrationPriceType.UsagePrice => "usage_price", - BulkWithProrationPriceType.FixedPrice => "fixed_price", - BulkWithProrationPriceType.CompositePrice => "composite_price", + GroupedWithProratedMinimumPriceType.UsagePrice => "usage_price", + GroupedWithProratedMinimumPriceType.FixedPrice => "fixed_price", + GroupedWithProratedMinimumPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -24022,10 +29575,112 @@ 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) + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseType, + GroupedWithProratedMinimumLicenseTypeFromRaw + >) )] -public sealed record class GroupedWithProratedMinimum : JsonModel +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) +)] +public sealed record class GroupedWithMeteredMinimum : JsonModel { public required string ID { @@ -24059,42 +29714,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -24111,12 +29766,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedWithProratedMinimumConversionRateConfig? ConversionRateConfig + public required GroupedWithMeteredMinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -24185,18 +29840,28 @@ public required double? FixedPriceQuantity } /// - /// Configuration for grouped_with_prorated_minimum pricing + /// Configuration for grouped_with_metered_minimum pricing /// - public required GroupedWithProratedMinimumGroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + public required GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_prorated_minimum_config" + return this._rawData.GetNotNullClass( + "grouped_with_metered_minimum_config" ); } - init { this._rawData.Set("grouped_with_prorated_minimum_config", value); } + init { this._rawData.Set("grouped_with_metered_minimum_config", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } public required BillingCycleConfiguration? InvoicingCycleConfiguration @@ -24323,13 +29988,13 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("price_type"); } init { this._rawData.Set("price_type", value); } @@ -24361,6 +30026,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() { @@ -24381,7 +30063,8 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedWithProratedMinimumConfig.Validate(); + this.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -24392,7 +30075,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_prorated_minimum") + JsonSerializer.SerializeToElement("grouped_with_metered_minimum") ) ) { @@ -24403,30 +30086,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 GroupedWithProratedMinimum() + public GroupedWithMeteredMinimum() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + 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 GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) - : base(groupedWithProratedMinimum) { } + public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) + : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedWithProratedMinimum(IReadOnlyDictionary rawData) + public GroupedWithMeteredMinimum(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); } #pragma warning disable CS8618 @@ -24434,14 +30121,14 @@ public GroupedWithProratedMinimum(IReadOnlyDictionary rawDa "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedWithProratedMinimum(FrozenDictionary rawData) + GroupedWithMeteredMinimum(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithProratedMinimum FromRawUnchecked( + /// + public static GroupedWithMeteredMinimum FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -24449,25 +30136,25 @@ IReadOnlyDictionary rawData } } -class GroupedWithProratedMinimumFromRaw : IFromRawJson +class GroupedWithMeteredMinimumFromRaw : IFromRawJson { /// - public GroupedWithProratedMinimum FromRawUnchecked( + public GroupedWithMeteredMinimum FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithProratedMinimum.FromRawUnchecked(rawData); + ) => GroupedWithMeteredMinimum.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithProratedMinimumBillingModeConverter))] -public enum GroupedWithProratedMinimumBillingMode +[JsonConverter(typeof(GroupedWithMeteredMinimumBillingModeConverter))] +public enum GroupedWithMeteredMinimumBillingMode { InAdvance, InArrear, } -sealed class GroupedWithProratedMinimumBillingModeConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumBillingModeConverter + : JsonConverter { - public override GroupedWithProratedMinimumBillingMode Read( + public override GroupedWithMeteredMinimumBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -24475,15 +30162,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedWithProratedMinimumBillingMode.InAdvance, - "in_arrear" => GroupedWithProratedMinimumBillingMode.InArrear, - _ => (GroupedWithProratedMinimumBillingMode)(-1), + "in_advance" => GroupedWithMeteredMinimumBillingMode.InAdvance, + "in_arrear" => GroupedWithMeteredMinimumBillingMode.InArrear, + _ => (GroupedWithMeteredMinimumBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumBillingMode value, + GroupedWithMeteredMinimumBillingMode value, JsonSerializerOptions options ) { @@ -24491,8 +30178,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithProratedMinimumBillingMode.InAdvance => "in_advance", - GroupedWithProratedMinimumBillingMode.InArrear => "in_arrear", + GroupedWithMeteredMinimumBillingMode.InAdvance => "in_advance", + GroupedWithMeteredMinimumBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -24502,8 +30189,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithProratedMinimumCadenceConverter))] -public enum GroupedWithProratedMinimumCadence +[JsonConverter(typeof(GroupedWithMeteredMinimumCadenceConverter))] +public enum GroupedWithMeteredMinimumCadence { OneTime, Monthly, @@ -24513,10 +30200,10 @@ public enum GroupedWithProratedMinimumCadence Custom, } -sealed class GroupedWithProratedMinimumCadenceConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumCadenceConverter + : JsonConverter { - public override GroupedWithProratedMinimumCadence Read( + public override GroupedWithMeteredMinimumCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -24524,19 +30211,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedWithProratedMinimumCadence.OneTime, - "monthly" => GroupedWithProratedMinimumCadence.Monthly, - "quarterly" => GroupedWithProratedMinimumCadence.Quarterly, - "semi_annual" => GroupedWithProratedMinimumCadence.SemiAnnual, - "annual" => GroupedWithProratedMinimumCadence.Annual, - "custom" => GroupedWithProratedMinimumCadence.Custom, - _ => (GroupedWithProratedMinimumCadence)(-1), + "one_time" => GroupedWithMeteredMinimumCadence.OneTime, + "monthly" => GroupedWithMeteredMinimumCadence.Monthly, + "quarterly" => GroupedWithMeteredMinimumCadence.Quarterly, + "semi_annual" => GroupedWithMeteredMinimumCadence.SemiAnnual, + "annual" => GroupedWithMeteredMinimumCadence.Annual, + "custom" => GroupedWithMeteredMinimumCadence.Custom, + _ => (GroupedWithMeteredMinimumCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumCadence value, + GroupedWithMeteredMinimumCadence value, JsonSerializerOptions options ) { @@ -24544,12 +30231,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithProratedMinimumCadence.OneTime => "one_time", - GroupedWithProratedMinimumCadence.Monthly => "monthly", - GroupedWithProratedMinimumCadence.Quarterly => "quarterly", - GroupedWithProratedMinimumCadence.SemiAnnual => "semi_annual", - GroupedWithProratedMinimumCadence.Annual => "annual", - GroupedWithProratedMinimumCadence.Custom => "custom", + GroupedWithMeteredMinimumCadence.OneTime => "one_time", + GroupedWithMeteredMinimumCadence.Monthly => "monthly", + GroupedWithMeteredMinimumCadence.Quarterly => "quarterly", + GroupedWithMeteredMinimumCadence.SemiAnnual => "semi_annual", + GroupedWithMeteredMinimumCadence.Annual => "annual", + GroupedWithMeteredMinimumCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -24561,22 +30248,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedWithProratedMinimumCompositePriceFilter, - GroupedWithProratedMinimumCompositePriceFilterFromRaw + GroupedWithMeteredMinimumCompositePriceFilter, + GroupedWithMeteredMinimumCompositePriceFilterFromRaw >) )] -public sealed record class GroupedWithProratedMinimumCompositePriceFilter : JsonModel +public sealed record class GroupedWithMeteredMinimumCompositePriceFilter : 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); } @@ -24585,13 +30272,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -24624,14 +30311,17 @@ public override void Validate() _ = this.Values; } - public GroupedWithProratedMinimumCompositePriceFilter() { } + public GroupedWithMeteredMinimumCompositePriceFilter() { } - public GroupedWithProratedMinimumCompositePriceFilter( - GroupedWithProratedMinimumCompositePriceFilter groupedWithProratedMinimumCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumCompositePriceFilter( + GroupedWithMeteredMinimumCompositePriceFilter groupedWithMeteredMinimumCompositePriceFilter ) - : base(groupedWithProratedMinimumCompositePriceFilter) { } + : base(groupedWithMeteredMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 - public GroupedWithProratedMinimumCompositePriceFilter( + public GroupedWithMeteredMinimumCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -24640,14 +30330,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithProratedMinimumCompositePriceFilter(FrozenDictionary rawData) + GroupedWithMeteredMinimumCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithProratedMinimumCompositePriceFilter FromRawUnchecked( + /// + public static GroupedWithMeteredMinimumCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -24655,20 +30345,20 @@ IReadOnlyDictionary rawData } } -class GroupedWithProratedMinimumCompositePriceFilterFromRaw - : IFromRawJson +class GroupedWithMeteredMinimumCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedWithProratedMinimumCompositePriceFilter FromRawUnchecked( + public GroupedWithMeteredMinimumCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithProratedMinimumCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedWithMeteredMinimumCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedWithProratedMinimumCompositePriceFilterFieldConverter))] -public enum GroupedWithProratedMinimumCompositePriceFilterField +[JsonConverter(typeof(GroupedWithMeteredMinimumCompositePriceFilterFieldConverter))] +public enum GroupedWithMeteredMinimumCompositePriceFilterField { PriceID, ItemID, @@ -24677,29 +30367,29 @@ public enum GroupedWithProratedMinimumCompositePriceFilterField PricingUnitID, } -sealed class GroupedWithProratedMinimumCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedWithProratedMinimumCompositePriceFilterField Read( + public override GroupedWithMeteredMinimumCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "price_id" => GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - "item_id" => GroupedWithProratedMinimumCompositePriceFilterField.ItemID, - "price_type" => GroupedWithProratedMinimumCompositePriceFilterField.PriceType, - "currency" => GroupedWithProratedMinimumCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID, - _ => (GroupedWithProratedMinimumCompositePriceFilterField)(-1), + return JsonSerializer.Deserialize(ref reader, options) switch + { + "price_id" => GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + "item_id" => GroupedWithMeteredMinimumCompositePriceFilterField.ItemID, + "price_type" => GroupedWithMeteredMinimumCompositePriceFilterField.PriceType, + "currency" => GroupedWithMeteredMinimumCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID, + _ => (GroupedWithMeteredMinimumCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumCompositePriceFilterField value, + GroupedWithMeteredMinimumCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -24707,11 +30397,11 @@ JsonSerializerOptions options writer, value switch { - GroupedWithProratedMinimumCompositePriceFilterField.PriceID => "price_id", - GroupedWithProratedMinimumCompositePriceFilterField.ItemID => "item_id", - GroupedWithProratedMinimumCompositePriceFilterField.PriceType => "price_type", - GroupedWithProratedMinimumCompositePriceFilterField.Currency => "currency", - GroupedWithProratedMinimumCompositePriceFilterField.PricingUnitID => + GroupedWithMeteredMinimumCompositePriceFilterField.PriceID => "price_id", + GroupedWithMeteredMinimumCompositePriceFilterField.ItemID => "item_id", + GroupedWithMeteredMinimumCompositePriceFilterField.PriceType => "price_type", + GroupedWithMeteredMinimumCompositePriceFilterField.Currency => "currency", + GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -24725,17 +30415,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedWithProratedMinimumCompositePriceFilterOperatorConverter))] -public enum GroupedWithProratedMinimumCompositePriceFilterOperator +[JsonConverter(typeof(GroupedWithMeteredMinimumCompositePriceFilterOperatorConverter))] +public enum GroupedWithMeteredMinimumCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedWithProratedMinimumCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedWithProratedMinimumCompositePriceFilterOperator Read( + public override GroupedWithMeteredMinimumCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -24743,15 +30433,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - "excludes" => GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes, - _ => (GroupedWithProratedMinimumCompositePriceFilterOperator)(-1), + "includes" => GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + "excludes" => GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes, + _ => (GroupedWithMeteredMinimumCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumCompositePriceFilterOperator value, + GroupedWithMeteredMinimumCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -24759,8 +30449,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithProratedMinimumCompositePriceFilterOperator.Includes => "includes", - GroupedWithProratedMinimumCompositePriceFilterOperator.Excludes => "excludes", + GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes => "includes", + GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -24770,8 +30460,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithProratedMinimumConversionRateConfigConverter))] -public record class GroupedWithProratedMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMeteredMinimumConversionRateConfigConverter))] +public record class GroupedWithMeteredMinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -24788,7 +30478,7 @@ public JsonElement Json } } - public GroupedWithProratedMinimumConversionRateConfig( + public GroupedWithMeteredMinimumConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -24797,7 +30487,7 @@ public GroupedWithProratedMinimumConversionRateConfig( this._element = element; } - public GroupedWithProratedMinimumConversionRateConfig( + public GroupedWithMeteredMinimumConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -24806,7 +30496,7 @@ public GroupedWithProratedMinimumConversionRateConfig( this._element = element; } - public GroupedWithProratedMinimumConversionRateConfig(JsonElement element) + public GroupedWithMeteredMinimumConversionRateConfig(JsonElement element) { this._element = element; } @@ -24815,7 +30505,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 +30526,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 +30546,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 +30557,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24888,7 +30578,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" ); } } @@ -24897,7 +30587,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 +30598,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24924,16 +30614,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" ), }; } - public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithProratedMinimumConversionRateConfig( + public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -24952,16 +30642,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithProratedMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" ); } 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(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -24969,13 +30659,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 GroupedWithProratedMinimumConversionRateConfigConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumConversionRateConfigConverter + : JsonConverter { - public override GroupedWithProratedMinimumConversionRateConfig? Read( + public override GroupedWithMeteredMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25004,12 +30707,10 @@ JsonSerializerOptions 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 +30727,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -25040,14 +30739,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithProratedMinimumConversionRateConfig(element); + return new GroupedWithMeteredMinimumConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumConversionRateConfig value, + GroupedWithMeteredMinimumConversionRateConfig value, JsonSerializerOptions options ) { @@ -25056,18 +30755,19 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_prorated_minimum pricing +/// Configuration for grouped_with_metered_minimum pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedWithProratedMinimumGroupedWithProratedMinimumConfig, - GroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig, + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw >) )] -public sealed record class GroupedWithProratedMinimumGroupedWithProratedMinimumConfig : JsonModel +public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig : JsonModel { /// - /// How to determine the groups that should each have a minimum + /// Used to partition the usage into groups. The minimum amount is applied to + /// each group. /// public required string GroupingKey { @@ -25080,47 +30780,113 @@ public required string GroupingKey } /// - /// The minimum amount to charge per group + /// The minimum amount to charge per group per unit /// - public required string Minimum + public required string MinimumUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum"); + return this._rawData.GetNotNullClass("minimum_unit_amount"); } - init { this._rawData.Set("minimum", value); } + init { this._rawData.Set("minimum_unit_amount", value); } } /// - /// The amount to charge per unit + /// Used to determine the unit rate /// - public required string UnitRate + public required string PricingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rate"); + 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)); } - init { this._rawData.Set("unit_rate", value); } } /// public override void Validate() { _ = this.GroupingKey; - _ = this.Minimum; - _ = this.UnitRate; + _ = this.MinimumUnitAmount; + _ = this.PricingKey; + foreach (var item in this.ScalingFactors) + { + item.Validate(); + } + _ = this.ScalingKey; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } } - public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig() { } + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() { } - public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( - GroupedWithProratedMinimumGroupedWithProratedMinimumConfig groupedWithProratedMinimumGroupedWithProratedMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig ) - : base(groupedWithProratedMinimumGroupedWithProratedMinimumConfig) { } + : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 - public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( IReadOnlyDictionary rawData ) { @@ -25129,7 +30895,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( FrozenDictionary rawData ) { @@ -25137,8 +30903,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static GroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + /// + public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -25146,27 +30912,204 @@ IReadOnlyDictionary rawData } } -class GroupedWithProratedMinimumGroupedWithProratedMinimumConfigFromRaw - : IFromRawJson +class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + : IFromRawJson { /// - public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig FromRawUnchecked( + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithProratedMinimumGroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithProratedMinimumPriceTypeConverter))] -public enum GroupedWithProratedMinimumPriceType +/// +/// Configuration for a scaling factor +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor, + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + : 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + ) + : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a unit amount +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount, + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + : 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + ) + : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(GroupedWithMeteredMinimumPriceTypeConverter))] +public enum GroupedWithMeteredMinimumPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class GroupedWithProratedMinimumPriceTypeConverter - : JsonConverter +sealed class GroupedWithMeteredMinimumPriceTypeConverter + : JsonConverter { - public override GroupedWithProratedMinimumPriceType Read( + public override GroupedWithMeteredMinimumPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25174,16 +31117,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => GroupedWithProratedMinimumPriceType.UsagePrice, - "fixed_price" => GroupedWithProratedMinimumPriceType.FixedPrice, - "composite_price" => GroupedWithProratedMinimumPriceType.CompositePrice, - _ => (GroupedWithProratedMinimumPriceType)(-1), + "usage_price" => GroupedWithMeteredMinimumPriceType.UsagePrice, + "fixed_price" => GroupedWithMeteredMinimumPriceType.FixedPrice, + "composite_price" => GroupedWithMeteredMinimumPriceType.CompositePrice, + _ => (GroupedWithMeteredMinimumPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithProratedMinimumPriceType value, + GroupedWithMeteredMinimumPriceType value, JsonSerializerOptions options ) { @@ -25191,9 +31134,9 @@ JsonSerializerOptions options writer, value switch { - GroupedWithProratedMinimumPriceType.UsagePrice => "usage_price", - GroupedWithProratedMinimumPriceType.FixedPrice => "fixed_price", - GroupedWithProratedMinimumPriceType.CompositePrice => "composite_price", + GroupedWithMeteredMinimumPriceType.UsagePrice => "usage_price", + GroupedWithMeteredMinimumPriceType.FixedPrice => "fixed_price", + GroupedWithMeteredMinimumPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -25203,10 +31146,112 @@ 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) + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseType, + GroupedWithMeteredMinimumLicenseTypeFromRaw + >) )] -public sealed record class GroupedWithMeteredMinimum : JsonModel +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) +)] +public sealed record class GroupedWithMinMaxThresholds : JsonModel { public required string ID { @@ -25240,42 +31285,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "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) ); @@ -25292,12 +31337,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedWithMeteredMinimumConversionRateConfig? ConversionRateConfig + public required GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -25366,18 +31411,28 @@ public required double? FixedPriceQuantity } /// - /// Configuration for grouped_with_metered_minimum pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_metered_minimum_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("grouped_with_metered_minimum_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } public required BillingCycleConfiguration? InvoicingCycleConfiguration @@ -25504,13 +31559,13 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("price_type"); } init { this._rawData.Set("price_type", value); } @@ -25542,6 +31597,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() { @@ -25562,7 +31634,8 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedWithMeteredMinimumConfig.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -25573,7 +31646,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_metered_minimum") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -25584,30 +31657,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 GroupedWithMeteredMinimum() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + 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 GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) - : base(groupedWithMeteredMinimum) { } + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedWithMeteredMinimum(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 @@ -25615,14 +31692,14 @@ public GroupedWithMeteredMinimum(IReadOnlyDictionary rawDat "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedWithMeteredMinimum(FrozenDictionary rawData) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMeteredMinimum FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -25630,25 +31707,25 @@ IReadOnlyDictionary rawData } } -class GroupedWithMeteredMinimumFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public GroupedWithMeteredMinimum FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMeteredMinimum.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithMeteredMinimumBillingModeConverter))] -public enum GroupedWithMeteredMinimumBillingMode +[JsonConverter(typeof(GroupedWithMinMaxThresholdsBillingModeConverter))] +public enum GroupedWithMinMaxThresholdsBillingMode { InAdvance, InArrear, } -sealed class GroupedWithMeteredMinimumBillingModeConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsBillingModeConverter + : JsonConverter { - public override GroupedWithMeteredMinimumBillingMode Read( + public override GroupedWithMinMaxThresholdsBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25656,15 +31733,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedWithMeteredMinimumBillingMode.InAdvance, - "in_arrear" => GroupedWithMeteredMinimumBillingMode.InArrear, - _ => (GroupedWithMeteredMinimumBillingMode)(-1), + "in_advance" => GroupedWithMinMaxThresholdsBillingMode.InAdvance, + "in_arrear" => GroupedWithMinMaxThresholdsBillingMode.InArrear, + _ => (GroupedWithMinMaxThresholdsBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMeteredMinimumBillingMode value, + GroupedWithMinMaxThresholdsBillingMode value, JsonSerializerOptions options ) { @@ -25672,8 +31749,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMeteredMinimumBillingMode.InAdvance => "in_advance", - GroupedWithMeteredMinimumBillingMode.InArrear => "in_arrear", + GroupedWithMinMaxThresholdsBillingMode.InAdvance => "in_advance", + GroupedWithMinMaxThresholdsBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -25683,8 +31760,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithMeteredMinimumCadenceConverter))] -public enum GroupedWithMeteredMinimumCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { OneTime, Monthly, @@ -25694,10 +31771,10 @@ public enum GroupedWithMeteredMinimumCadence Custom, } -sealed class GroupedWithMeteredMinimumCadenceConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override GroupedWithMeteredMinimumCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25705,19 +31782,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedWithMeteredMinimumCadence.OneTime, - "monthly" => GroupedWithMeteredMinimumCadence.Monthly, - "quarterly" => GroupedWithMeteredMinimumCadence.Quarterly, - "semi_annual" => GroupedWithMeteredMinimumCadence.SemiAnnual, - "annual" => GroupedWithMeteredMinimumCadence.Annual, - "custom" => GroupedWithMeteredMinimumCadence.Custom, - _ => (GroupedWithMeteredMinimumCadence)(-1), + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMeteredMinimumCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -25725,12 +31802,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMeteredMinimumCadence.OneTime => "one_time", - GroupedWithMeteredMinimumCadence.Monthly => "monthly", - GroupedWithMeteredMinimumCadence.Quarterly => "quarterly", - GroupedWithMeteredMinimumCadence.SemiAnnual => "semi_annual", - GroupedWithMeteredMinimumCadence.Annual => "annual", - GroupedWithMeteredMinimumCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -25742,22 +31819,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedWithMeteredMinimumCompositePriceFilter, - GroupedWithMeteredMinimumCompositePriceFilterFromRaw + GroupedWithMinMaxThresholdsCompositePriceFilter, + GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw >) )] -public sealed record class GroupedWithMeteredMinimumCompositePriceFilter : JsonModel +public sealed record class GroupedWithMinMaxThresholdsCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -25766,13 +31843,16 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + GroupedWithMinMaxThresholdsCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -25805,14 +31885,17 @@ public override void Validate() _ = this.Values; } - public GroupedWithMeteredMinimumCompositePriceFilter() { } + public GroupedWithMinMaxThresholdsCompositePriceFilter() { } - public GroupedWithMeteredMinimumCompositePriceFilter( - GroupedWithMeteredMinimumCompositePriceFilter groupedWithMeteredMinimumCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsCompositePriceFilter( + GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter ) - : base(groupedWithMeteredMinimumCompositePriceFilter) { } + : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } +#pragma warning restore CS8618 - public GroupedWithMeteredMinimumCompositePriceFilter( + public GroupedWithMinMaxThresholdsCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -25821,14 +31904,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMeteredMinimumCompositePriceFilter(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMeteredMinimumCompositePriceFilter FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -25836,20 +31919,20 @@ IReadOnlyDictionary rawData } } -class GroupedWithMeteredMinimumCompositePriceFilterFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedWithMeteredMinimumCompositePriceFilter FromRawUnchecked( + public GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMeteredMinimumCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedWithMeteredMinimumCompositePriceFilterFieldConverter))] -public enum GroupedWithMeteredMinimumCompositePriceFilterField +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter))] +public enum GroupedWithMinMaxThresholdsCompositePriceFilterField { PriceID, ItemID, @@ -25858,10 +31941,10 @@ public enum GroupedWithMeteredMinimumCompositePriceFilterField PricingUnitID, } -sealed class GroupedWithMeteredMinimumCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedWithMeteredMinimumCompositePriceFilterField Read( + public override GroupedWithMinMaxThresholdsCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25869,18 +31952,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - "item_id" => GroupedWithMeteredMinimumCompositePriceFilterField.ItemID, - "price_type" => GroupedWithMeteredMinimumCompositePriceFilterField.PriceType, - "currency" => GroupedWithMeteredMinimumCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID, - _ => (GroupedWithMeteredMinimumCompositePriceFilterField)(-1), + "price_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + "item_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID, + "price_type" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType, + "currency" => GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID, + _ => (GroupedWithMinMaxThresholdsCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMeteredMinimumCompositePriceFilterField value, + GroupedWithMinMaxThresholdsCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -25888,11 +31971,11 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMeteredMinimumCompositePriceFilterField.PriceID => "price_id", - GroupedWithMeteredMinimumCompositePriceFilterField.ItemID => "item_id", - GroupedWithMeteredMinimumCompositePriceFilterField.PriceType => "price_type", - GroupedWithMeteredMinimumCompositePriceFilterField.Currency => "currency", - GroupedWithMeteredMinimumCompositePriceFilterField.PricingUnitID => + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID => "price_id", + GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID => "item_id", + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType => "price_type", + GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency => "currency", + GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -25906,17 +31989,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedWithMeteredMinimumCompositePriceFilterOperatorConverter))] -public enum GroupedWithMeteredMinimumCompositePriceFilterOperator +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter))] +public enum GroupedWithMinMaxThresholdsCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedWithMeteredMinimumCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedWithMeteredMinimumCompositePriceFilterOperator Read( + public override GroupedWithMinMaxThresholdsCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -25924,15 +32007,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, - "excludes" => GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes, - _ => (GroupedWithMeteredMinimumCompositePriceFilterOperator)(-1), + "includes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + "excludes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes, + _ => (GroupedWithMinMaxThresholdsCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMeteredMinimumCompositePriceFilterOperator value, + GroupedWithMinMaxThresholdsCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -25940,8 +32023,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes => "includes", - GroupedWithMeteredMinimumCompositePriceFilterOperator.Excludes => "excludes", + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes => "includes", + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -25951,8 +32034,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithMeteredMinimumConversionRateConfigConverter))] -public record class GroupedWithMeteredMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -25969,7 +32052,7 @@ public JsonElement Json } } - public GroupedWithMeteredMinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -25978,7 +32061,7 @@ public GroupedWithMeteredMinimumConversionRateConfig( this._element = element; } - public GroupedWithMeteredMinimumConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -25987,7 +32070,7 @@ public GroupedWithMeteredMinimumConversionRateConfig( this._element = element; } - public GroupedWithMeteredMinimumConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -25996,7 +32079,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 +32100,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 +32120,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 +32131,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26069,7 +32152,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -26078,7 +32161,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 +32172,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26105,16 +32188,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithMeteredMinimumConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -26133,16 +32216,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMeteredMinimumConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } 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(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -26150,13 +32233,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 GroupedWithMeteredMinimumConversionRateConfigConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override GroupedWithMeteredMinimumConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -26185,12 +32281,10 @@ JsonSerializerOptions 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 +32301,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -26221,14 +32313,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithMeteredMinimumConversionRateConfig(element); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithMeteredMinimumConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -26237,19 +32329,18 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_metered_minimum pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig, - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Used to partition the usage into groups. The minimum amount is applied to - /// each group. + /// The event property used to group before applying thresholds /// public required string GroupingKey { @@ -26262,128 +32353,78 @@ public required string GroupingKey } /// - /// 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. + /// The maximum amount to charge each group /// - public required IReadOnlyList ScalingFactors + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("scaling_factors"); - } - init - { - this._rawData.Set< - ImmutableArray - >("scaling_factors", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("maximum_charge"); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// Used to determine the unit rate scaling factor + /// The minimum amount to charge each group, regardless of usage /// - public required string ScalingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("scaling_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("scaling_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// Apply per unit pricing to each pricing value. The minimum amount is applied - /// any unmatched usage. + /// The base price charged per group /// - public required IReadOnlyList UnitAmounts + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("unit_amounts"); - } - init - { - this._rawData.Set< - ImmutableArray - >("unit_amounts", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("per_unit_rate"); } + init { this._rawData.Set("per_unit_rate", 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(); - } + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() { } + public GroupedWithMinMaxThresholdsConfig() { } - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) - : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig) { } + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( - IReadOnlyDictionary rawData - ) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( - FrozenDictionary rawData - ) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -26391,167 +32432,148 @@ IReadOnlyDictionary rawData } } -class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -/// -/// Configuration for a scaling factor -/// -[JsonConverter( - typeof(JsonModelConverter< - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor, - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw - >) -)] -public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor - : JsonModel +[JsonConverter(typeof(GroupedWithMinMaxThresholdsPriceTypeConverter))] +public enum GroupedWithMinMaxThresholdsPriceType { - 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 GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() { } - - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor - ) - : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor) { } - - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + UsagePrice, + FixedPrice, + CompositePrice, +} -#pragma warning disable CS8618 - [SetsRequiredMembers] - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( - FrozenDictionary rawData +sealed class GroupedWithMinMaxThresholdsPriceTypeConverter + : JsonConverter +{ + public override GroupedWithMinMaxThresholdsPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this._rawData = new(rawData); + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => GroupedWithMinMaxThresholdsPriceType.UsagePrice, + "fixed_price" => GroupedWithMinMaxThresholdsPriceType.FixedPrice, + "composite_price" => GroupedWithMinMaxThresholdsPriceType.CompositePrice, + _ => (GroupedWithMinMaxThresholdsPriceType)(-1), + }; } -#pragma warning restore CS8618 - /// - public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + GroupedWithMinMaxThresholdsPriceType value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorFromRaw - : IFromRawJson -{ - /// - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor.FromRawUnchecked( - rawData + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithMinMaxThresholdsPriceType.UsagePrice => "usage_price", + GroupedWithMinMaxThresholdsPriceType.FixedPrice => "fixed_price", + GroupedWithMinMaxThresholdsPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options ); + } } /// -/// Configuration for a unit amount +/// 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< - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount, - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw + GroupedWithMinMaxThresholdsLicenseType, + GroupedWithMinMaxThresholdsLicenseTypeFromRaw >) )] -public sealed record class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount - : JsonModel +public sealed record class GroupedWithMinMaxThresholdsLicenseType : JsonModel { - public required string PricingValue + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("pricing_value"); + return this._rawData.GetNotNullClass("id"); } - init { this._rawData.Set("pricing_value", value); } + init { this._rawData.Set("id", value); } } /// - /// Per unit amount + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. /// - public required string UnitAmount + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("unit_amount", value); } + 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.PricingValue; - _ = this.UnitAmount; + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; } - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() { } + public GroupedWithMinMaxThresholdsLicenseType() { } - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseType( + GroupedWithMinMaxThresholdsLicenseType groupedWithMinMaxThresholdsLicenseType ) - : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount) { } + : base(groupedWithMinMaxThresholdsLicenseType) { } +#pragma warning restore CS8618 - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( - IReadOnlyDictionary rawData - ) + public GroupedWithMinMaxThresholdsLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( - FrozenDictionary rawData - ) + GroupedWithMinMaxThresholdsLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -26559,70 +32581,17 @@ IReadOnlyDictionary rawData } } -class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsLicenseTypeFromRaw + : IFromRawJson { /// - public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount FromRawUnchecked( + public GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => - GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount.FromRawUnchecked( - rawData - ); -} - -[JsonConverter(typeof(GroupedWithMeteredMinimumPriceTypeConverter))] -public enum GroupedWithMeteredMinimumPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class GroupedWithMeteredMinimumPriceTypeConverter - : JsonConverter -{ - public override GroupedWithMeteredMinimumPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => GroupedWithMeteredMinimumPriceType.UsagePrice, - "fixed_price" => GroupedWithMeteredMinimumPriceType.FixedPrice, - "composite_price" => GroupedWithMeteredMinimumPriceType.CompositePrice, - _ => (GroupedWithMeteredMinimumPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMeteredMinimumPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMeteredMinimumPriceType.UsagePrice => "usage_price", - GroupedWithMeteredMinimumPriceType.FixedPrice => "fixed_price", - GroupedWithMeteredMinimumPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => GroupedWithMinMaxThresholdsLicenseType.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithDisplayName : JsonModel { public required string ID { @@ -26656,42 +32625,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); + return this._rawData.GetNotNullClass>( + "billing_mode" + ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -26708,12 +32677,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public required MatrixWithDisplayNameConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -26781,19 +32750,14 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } public required BillingCycleConfiguration? InvoicingCycleConfiguration @@ -26821,6 +32785,21 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } + /// + /// Configuration for matrix_with_display_name pricing + /// + public required MatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_config", value); } + } + [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -26920,14 +32899,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); + return this._rawData.GetNotNullClass>( + "price_type" + ); } init { this._rawData.Set("price_type", value); } } @@ -26958,6 +32937,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() { @@ -26978,9 +32972,10 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); + this.MatrixWithDisplayNameConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -26989,7 +32984,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("matrix_with_display_name") ) ) { @@ -27000,30 +32995,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 GroupedWithMinMaxThresholds() + public MatrixWithDisplayName() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + 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 GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) - : base(groupedWithMinMaxThresholds) { } + public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) + : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public MatrixWithDisplayName(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); } #pragma warning disable CS8618 @@ -27031,14 +33030,14 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + MatrixWithDisplayName(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static MatrixWithDisplayName FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -27046,25 +33045,25 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson +class MatrixWithDisplayNameFromRaw : IFromRawJson { /// - public GroupedWithMinMaxThresholds FromRawUnchecked( + public MatrixWithDisplayName FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => MatrixWithDisplayName.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsBillingModeConverter))] -public enum GroupedWithMinMaxThresholdsBillingMode +[JsonConverter(typeof(MatrixWithDisplayNameBillingModeConverter))] +public enum MatrixWithDisplayNameBillingMode { InAdvance, InArrear, } -sealed class GroupedWithMinMaxThresholdsBillingModeConverter - : JsonConverter +sealed class MatrixWithDisplayNameBillingModeConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsBillingMode Read( + public override MatrixWithDisplayNameBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27072,15 +33071,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedWithMinMaxThresholdsBillingMode.InAdvance, - "in_arrear" => GroupedWithMinMaxThresholdsBillingMode.InArrear, - _ => (GroupedWithMinMaxThresholdsBillingMode)(-1), + "in_advance" => MatrixWithDisplayNameBillingMode.InAdvance, + "in_arrear" => MatrixWithDisplayNameBillingMode.InArrear, + _ => (MatrixWithDisplayNameBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsBillingMode value, + MatrixWithDisplayNameBillingMode value, JsonSerializerOptions options ) { @@ -27088,8 +33087,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsBillingMode.InAdvance => "in_advance", - GroupedWithMinMaxThresholdsBillingMode.InArrear => "in_arrear", + MatrixWithDisplayNameBillingMode.InAdvance => "in_advance", + MatrixWithDisplayNameBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -27099,8 +33098,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] +public enum MatrixWithDisplayNameCadence { OneTime, Monthly, @@ -27110,10 +33109,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsCadence Read( + public override MatrixWithDisplayNameCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27121,19 +33119,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, - "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, - "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "annual" => GroupedWithMinMaxThresholdsCadence.Annual, - "custom" => GroupedWithMinMaxThresholdsCadence.Custom, - _ => (GroupedWithMinMaxThresholdsCadence)(-1), + "one_time" => MatrixWithDisplayNameCadence.OneTime, + "monthly" => MatrixWithDisplayNameCadence.Monthly, + "quarterly" => MatrixWithDisplayNameCadence.Quarterly, + "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, + "annual" => MatrixWithDisplayNameCadence.Annual, + "custom" => MatrixWithDisplayNameCadence.Custom, + _ => (MatrixWithDisplayNameCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCadence value, + MatrixWithDisplayNameCadence value, JsonSerializerOptions options ) { @@ -27141,12 +33139,12 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - GroupedWithMinMaxThresholdsCadence.Annual => "annual", - GroupedWithMinMaxThresholdsCadence.Custom => "custom", + MatrixWithDisplayNameCadence.OneTime => "one_time", + MatrixWithDisplayNameCadence.Monthly => "monthly", + MatrixWithDisplayNameCadence.Quarterly => "quarterly", + MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", + MatrixWithDisplayNameCadence.Annual => "annual", + MatrixWithDisplayNameCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -27158,22 +33156,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsCompositePriceFilter, - GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw + MatrixWithDisplayNameCompositePriceFilter, + MatrixWithDisplayNameCompositePriceFilterFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsCompositePriceFilter : JsonModel +public sealed record class MatrixWithDisplayNameCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -27182,16 +33180,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum< - string, - GroupedWithMinMaxThresholdsCompositePriceFilterOperator - > Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -27224,14 +33219,17 @@ public override void Validate() _ = this.Values; } - public GroupedWithMinMaxThresholdsCompositePriceFilter() { } + public MatrixWithDisplayNameCompositePriceFilter() { } - public GroupedWithMinMaxThresholdsCompositePriceFilter( - GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameCompositePriceFilter( + MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter ) - : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } + : base(matrixWithDisplayNameCompositePriceFilter) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsCompositePriceFilter( + public MatrixWithDisplayNameCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -27240,14 +33238,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsCompositePriceFilter(FrozenDictionary rawData) + MatrixWithDisplayNameCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( + /// + public static MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -27255,20 +33253,20 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw - : IFromRawJson +class MatrixWithDisplayNameCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( + public MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsCompositePriceFilter.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter))] -public enum GroupedWithMinMaxThresholdsCompositePriceFilterField +[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterFieldConverter))] +public enum MatrixWithDisplayNameCompositePriceFilterField { PriceID, ItemID, @@ -27277,10 +33275,10 @@ public enum GroupedWithMinMaxThresholdsCompositePriceFilterField PricingUnitID, } -sealed class GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter - : JsonConverter +sealed class MatrixWithDisplayNameCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsCompositePriceFilterField Read( + public override MatrixWithDisplayNameCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27288,18 +33286,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - "item_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID, - "price_type" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType, - "currency" => GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID, - _ => (GroupedWithMinMaxThresholdsCompositePriceFilterField)(-1), + "price_id" => MatrixWithDisplayNameCompositePriceFilterField.PriceID, + "item_id" => MatrixWithDisplayNameCompositePriceFilterField.ItemID, + "price_type" => MatrixWithDisplayNameCompositePriceFilterField.PriceType, + "currency" => MatrixWithDisplayNameCompositePriceFilterField.Currency, + "pricing_unit_id" => MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID, + _ => (MatrixWithDisplayNameCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCompositePriceFilterField value, + MatrixWithDisplayNameCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -27307,12 +33305,11 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID => "price_id", - GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID => "item_id", - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType => "price_type", - GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency => "currency", - GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", + MatrixWithDisplayNameCompositePriceFilterField.PriceID => "price_id", + MatrixWithDisplayNameCompositePriceFilterField.ItemID => "item_id", + MatrixWithDisplayNameCompositePriceFilterField.PriceType => "price_type", + MatrixWithDisplayNameCompositePriceFilterField.Currency => "currency", + MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -27325,17 +33322,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter))] -public enum GroupedWithMinMaxThresholdsCompositePriceFilterOperator +[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterOperatorConverter))] +public enum MatrixWithDisplayNameCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MatrixWithDisplayNameCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsCompositePriceFilterOperator Read( + public override MatrixWithDisplayNameCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27343,15 +33340,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - "excludes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes, - _ => (GroupedWithMinMaxThresholdsCompositePriceFilterOperator)(-1), + "includes" => MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + "excludes" => MatrixWithDisplayNameCompositePriceFilterOperator.Excludes, + _ => (MatrixWithDisplayNameCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCompositePriceFilterOperator value, + MatrixWithDisplayNameCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -27359,8 +33356,8 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes => "includes", - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes => "excludes", + MatrixWithDisplayNameCompositePriceFilterOperator.Includes => "includes", + MatrixWithDisplayNameCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -27370,8 +33367,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] +public record class MatrixWithDisplayNameConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -27388,7 +33385,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithDisplayNameConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -27397,7 +33394,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MatrixWithDisplayNameConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -27406,7 +33403,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public MatrixWithDisplayNameConversionRateConfig(JsonElement element) { this._element = element; } @@ -27415,7 +33412,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 +33433,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 +33453,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 +33464,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27488,7 +33485,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" ); } } @@ -27497,7 +33494,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 +33505,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27524,16 +33521,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 MatrixWithDisplayNameConversionRateConfig" ), }; } - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithDisplayNameConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MatrixWithDisplayNameConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -27552,16 +33549,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 MatrixWithDisplayNameConversionRateConfig" ); } 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(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -27569,13 +33566,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 MatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter { - public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override MatrixWithDisplayNameConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27604,12 +33614,10 @@ JsonSerializerOptions 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 +33634,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -27640,14 +33646,14 @@ JsonSerializerOptions options } default: { - return new GroupedWithMinMaxThresholdsConversionRateConfig(element); + return new MatrixWithDisplayNameConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsConversionRateConfig value, + MatrixWithDisplayNameConversionRateConfig value, JsonSerializerOptions options ) { @@ -27656,99 +33662,189 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for matrix_with_display_name pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsConfig, - GroupedWithMinMaxThresholdsConfigFromRaw + MatrixWithDisplayNameMatrixWithDisplayNameConfig, + MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Used to determine the unit rate /// - public required string GroupingKey + public required string Dimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("dimension"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("dimension", value); } } /// - /// The maximum amount to charge each group + /// Apply per unit pricing to each dimension value /// - public required string MaximumCharge + public required IReadOnlyList UnitAmounts { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("unit_amounts"); + } + init + { + this._rawData.Set< + ImmutableArray + >("unit_amounts", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("maximum_charge", value); } } + /// + public override void Validate() + { + _ = this.Dimension; + foreach (var item in this.UnitAmounts) + { + item.Validate(); + } + } + + public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameMatrixWithDisplayNameConfig( + MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig + ) + : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameMatrixWithDisplayNameConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameMatrixWithDisplayNameConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + : IFromRawJson +{ + /// + public MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a unit amount item +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// The dimension value /// - public required string MinimumCharge + public required string DimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("dimension_value"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("dimension_value", value); } } /// - /// The base price charged per group + /// Display name for this dimension value /// - public required string PerUnitRate + public required string DisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("display_name"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("display_name", value); } + } + + /// + /// Per unit amount + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; } - public GroupedWithMinMaxThresholdsConfig() { } + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } - public GroupedWithMinMaxThresholdsConfig( - GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -27756,26 +33852,26 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson { /// - public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedWithMinMaxThresholdsPriceTypeConverter))] -public enum GroupedWithMinMaxThresholdsPriceType +[JsonConverter(typeof(MatrixWithDisplayNamePriceTypeConverter))] +public enum MatrixWithDisplayNamePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class GroupedWithMinMaxThresholdsPriceTypeConverter - : JsonConverter +sealed class MatrixWithDisplayNamePriceTypeConverter : JsonConverter { - public override GroupedWithMinMaxThresholdsPriceType Read( + public override MatrixWithDisplayNamePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -27783,16 +33879,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => GroupedWithMinMaxThresholdsPriceType.UsagePrice, - "fixed_price" => GroupedWithMinMaxThresholdsPriceType.FixedPrice, - "composite_price" => GroupedWithMinMaxThresholdsPriceType.CompositePrice, - _ => (GroupedWithMinMaxThresholdsPriceType)(-1), + "usage_price" => MatrixWithDisplayNamePriceType.UsagePrice, + "fixed_price" => MatrixWithDisplayNamePriceType.FixedPrice, + "composite_price" => MatrixWithDisplayNamePriceType.CompositePrice, + _ => (MatrixWithDisplayNamePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsPriceType value, + MatrixWithDisplayNamePriceType value, JsonSerializerOptions options ) { @@ -27800,9 +33896,9 @@ JsonSerializerOptions options writer, value switch { - GroupedWithMinMaxThresholdsPriceType.UsagePrice => "usage_price", - GroupedWithMinMaxThresholdsPriceType.FixedPrice => "fixed_price", - GroupedWithMinMaxThresholdsPriceType.CompositePrice => "composite_price", + MatrixWithDisplayNamePriceType.UsagePrice => "usage_price", + MatrixWithDisplayNamePriceType.FixedPrice => "fixed_price", + MatrixWithDisplayNamePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -27812,8 +33908,109 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MatrixWithDisplayName : 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< + 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 { public required string ID { @@ -27847,42 +34044,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -27899,12 +34096,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required MatrixWithDisplayNameConversionRateConfig? ConversionRateConfig + public required GroupedTieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -27972,6 +34169,31 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + /// + /// Configuration for grouped_tiered_package pricing + /// + public required GroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", value); } + } + + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -27997,21 +34219,6 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } - /// - /// Configuration for matrix_with_display_name pricing - /// - public required MatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "matrix_with_display_name_config" - ); - } - init { this._rawData.Set("matrix_with_display_name_config", value); } - } - [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -28111,12 +34318,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -28149,6 +34356,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() { @@ -28169,9 +34391,10 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + this.GroupedTieredPackageConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); - this.MatrixWithDisplayNameConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -28180,7 +34403,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("matrix_with_display_name") + JsonSerializer.SerializeToElement("grouped_tiered_package") ) ) { @@ -28191,30 +34414,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 MatrixWithDisplayName() + public GroupedTieredPackage() { - this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + 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 MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) - : base(matrixWithDisplayName) { } + public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) + : base(groupedTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MatrixWithDisplayName(IReadOnlyDictionary rawData) + public GroupedTieredPackage(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); } #pragma warning disable CS8618 @@ -28222,14 +34449,14 @@ public MatrixWithDisplayName(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - MatrixWithDisplayName(FrozenDictionary rawData) + GroupedTieredPackage(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayName FromRawUnchecked( + /// + public static GroupedTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -28237,25 +34464,25 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameFromRaw : IFromRawJson +class GroupedTieredPackageFromRaw : IFromRawJson { /// - public MatrixWithDisplayName FromRawUnchecked( + public GroupedTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayName.FromRawUnchecked(rawData); + ) => GroupedTieredPackage.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MatrixWithDisplayNameBillingModeConverter))] -public enum MatrixWithDisplayNameBillingMode +[JsonConverter(typeof(GroupedTieredPackageBillingModeConverter))] +public enum GroupedTieredPackageBillingMode { InAdvance, InArrear, } -sealed class MatrixWithDisplayNameBillingModeConverter - : JsonConverter +sealed class GroupedTieredPackageBillingModeConverter + : JsonConverter { - public override MatrixWithDisplayNameBillingMode Read( + public override GroupedTieredPackageBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28263,15 +34490,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => MatrixWithDisplayNameBillingMode.InAdvance, - "in_arrear" => MatrixWithDisplayNameBillingMode.InArrear, - _ => (MatrixWithDisplayNameBillingMode)(-1), + "in_advance" => GroupedTieredPackageBillingMode.InAdvance, + "in_arrear" => GroupedTieredPackageBillingMode.InArrear, + _ => (GroupedTieredPackageBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameBillingMode value, + GroupedTieredPackageBillingMode value, JsonSerializerOptions options ) { @@ -28279,8 +34506,8 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameBillingMode.InAdvance => "in_advance", - MatrixWithDisplayNameBillingMode.InArrear => "in_arrear", + GroupedTieredPackageBillingMode.InAdvance => "in_advance", + GroupedTieredPackageBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28290,8 +34517,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] -public enum MatrixWithDisplayNameCadence +[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] +public enum GroupedTieredPackageCadence { OneTime, Monthly, @@ -28301,9 +34528,9 @@ public enum MatrixWithDisplayNameCadence Custom, } -sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter +sealed class GroupedTieredPackageCadenceConverter : JsonConverter { - public override MatrixWithDisplayNameCadence Read( + public override GroupedTieredPackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28311,19 +34538,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => MatrixWithDisplayNameCadence.OneTime, - "monthly" => MatrixWithDisplayNameCadence.Monthly, - "quarterly" => MatrixWithDisplayNameCadence.Quarterly, - "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, - "annual" => MatrixWithDisplayNameCadence.Annual, - "custom" => MatrixWithDisplayNameCadence.Custom, - _ => (MatrixWithDisplayNameCadence)(-1), + "one_time" => GroupedTieredPackageCadence.OneTime, + "monthly" => GroupedTieredPackageCadence.Monthly, + "quarterly" => GroupedTieredPackageCadence.Quarterly, + "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, + "annual" => GroupedTieredPackageCadence.Annual, + "custom" => GroupedTieredPackageCadence.Custom, + _ => (GroupedTieredPackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCadence value, + GroupedTieredPackageCadence value, JsonSerializerOptions options ) { @@ -28331,12 +34558,12 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCadence.OneTime => "one_time", - MatrixWithDisplayNameCadence.Monthly => "monthly", - MatrixWithDisplayNameCadence.Quarterly => "quarterly", - MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", - MatrixWithDisplayNameCadence.Annual => "annual", - MatrixWithDisplayNameCadence.Custom => "custom", + GroupedTieredPackageCadence.OneTime => "one_time", + GroupedTieredPackageCadence.Monthly => "monthly", + GroupedTieredPackageCadence.Quarterly => "quarterly", + GroupedTieredPackageCadence.SemiAnnual => "semi_annual", + GroupedTieredPackageCadence.Annual => "annual", + GroupedTieredPackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28348,22 +34575,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - MatrixWithDisplayNameCompositePriceFilter, - MatrixWithDisplayNameCompositePriceFilterFromRaw + GroupedTieredPackageCompositePriceFilter, + GroupedTieredPackageCompositePriceFilterFromRaw >) )] -public sealed record class MatrixWithDisplayNameCompositePriceFilter : JsonModel +public sealed record class GroupedTieredPackageCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -28372,13 +34599,13 @@ public required ApiEnum /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -28411,14 +34638,17 @@ public override void Validate() _ = this.Values; } - public MatrixWithDisplayNameCompositePriceFilter() { } + public GroupedTieredPackageCompositePriceFilter() { } - public MatrixWithDisplayNameCompositePriceFilter( - MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageCompositePriceFilter( + GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter ) - : base(matrixWithDisplayNameCompositePriceFilter) { } + : base(groupedTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 - public MatrixWithDisplayNameCompositePriceFilter( + public GroupedTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -28427,14 +34657,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MatrixWithDisplayNameCompositePriceFilter(FrozenDictionary rawData) + GroupedTieredPackageCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( + /// + public static GroupedTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -28442,20 +34672,20 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameCompositePriceFilterFromRaw - : IFromRawJson +class GroupedTieredPackageCompositePriceFilterFromRaw + : IFromRawJson { /// - public MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( + public GroupedTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterFieldConverter))] -public enum MatrixWithDisplayNameCompositePriceFilterField +[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterFieldConverter))] +public enum GroupedTieredPackageCompositePriceFilterField { PriceID, ItemID, @@ -28464,10 +34694,10 @@ public enum MatrixWithDisplayNameCompositePriceFilterField PricingUnitID, } -sealed class MatrixWithDisplayNameCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedTieredPackageCompositePriceFilterFieldConverter + : JsonConverter { - public override MatrixWithDisplayNameCompositePriceFilterField Read( + public override GroupedTieredPackageCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28475,18 +34705,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => MatrixWithDisplayNameCompositePriceFilterField.PriceID, - "item_id" => MatrixWithDisplayNameCompositePriceFilterField.ItemID, - "price_type" => MatrixWithDisplayNameCompositePriceFilterField.PriceType, - "currency" => MatrixWithDisplayNameCompositePriceFilterField.Currency, - "pricing_unit_id" => MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID, - _ => (MatrixWithDisplayNameCompositePriceFilterField)(-1), + "price_id" => GroupedTieredPackageCompositePriceFilterField.PriceID, + "item_id" => GroupedTieredPackageCompositePriceFilterField.ItemID, + "price_type" => GroupedTieredPackageCompositePriceFilterField.PriceType, + "currency" => GroupedTieredPackageCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedTieredPackageCompositePriceFilterField.PricingUnitID, + _ => (GroupedTieredPackageCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCompositePriceFilterField value, + GroupedTieredPackageCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -28494,11 +34724,11 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCompositePriceFilterField.PriceID => "price_id", - MatrixWithDisplayNameCompositePriceFilterField.ItemID => "item_id", - MatrixWithDisplayNameCompositePriceFilterField.PriceType => "price_type", - MatrixWithDisplayNameCompositePriceFilterField.Currency => "currency", - MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + GroupedTieredPackageCompositePriceFilterField.PriceID => "price_id", + GroupedTieredPackageCompositePriceFilterField.ItemID => "item_id", + GroupedTieredPackageCompositePriceFilterField.PriceType => "price_type", + GroupedTieredPackageCompositePriceFilterField.Currency => "currency", + GroupedTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28511,17 +34741,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterOperatorConverter))] -public enum MatrixWithDisplayNameCompositePriceFilterOperator +[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterOperatorConverter))] +public enum GroupedTieredPackageCompositePriceFilterOperator { Includes, Excludes, } -sealed class MatrixWithDisplayNameCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedTieredPackageCompositePriceFilterOperatorConverter + : JsonConverter { - public override MatrixWithDisplayNameCompositePriceFilterOperator Read( + public override GroupedTieredPackageCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28529,15 +34759,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => MatrixWithDisplayNameCompositePriceFilterOperator.Includes, - "excludes" => MatrixWithDisplayNameCompositePriceFilterOperator.Excludes, - _ => (MatrixWithDisplayNameCompositePriceFilterOperator)(-1), + "includes" => GroupedTieredPackageCompositePriceFilterOperator.Includes, + "excludes" => GroupedTieredPackageCompositePriceFilterOperator.Excludes, + _ => (GroupedTieredPackageCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCompositePriceFilterOperator value, + GroupedTieredPackageCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -28545,8 +34775,8 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCompositePriceFilterOperator.Includes => "includes", - MatrixWithDisplayNameCompositePriceFilterOperator.Excludes => "excludes", + GroupedTieredPackageCompositePriceFilterOperator.Includes => "includes", + GroupedTieredPackageCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28556,8 +34786,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] -public record class MatrixWithDisplayNameConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] +public record class GroupedTieredPackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -28574,7 +34804,7 @@ public JsonElement Json } } - public MatrixWithDisplayNameConversionRateConfig( + public GroupedTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -28583,7 +34813,7 @@ public MatrixWithDisplayNameConversionRateConfig( this._element = element; } - public MatrixWithDisplayNameConversionRateConfig( + public GroupedTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -28592,7 +34822,7 @@ public MatrixWithDisplayNameConversionRateConfig( this._element = element; } - public MatrixWithDisplayNameConversionRateConfig(JsonElement element) + public GroupedTieredPackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -28601,7 +34831,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 +34852,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 +34872,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 +34883,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28674,7 +34904,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ); } } @@ -28683,7 +34913,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 +34924,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28710,16 +34940,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ), }; } - public static implicit operator MatrixWithDisplayNameConversionRateConfig( + public static implicit operator GroupedTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MatrixWithDisplayNameConversionRateConfig( + public static implicit operator GroupedTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -28738,16 +34968,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ); } 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(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -28755,13 +34985,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 MatrixWithDisplayNameConversionRateConfigConverter - : JsonConverter +sealed class GroupedTieredPackageConversionRateConfigConverter + : JsonConverter { - public override MatrixWithDisplayNameConversionRateConfig? Read( + public override GroupedTieredPackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28790,12 +35033,10 @@ JsonSerializerOptions 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 +35053,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -28826,14 +35065,14 @@ JsonSerializerOptions options } default: { - return new MatrixWithDisplayNameConversionRateConfig(element); + return new GroupedTieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameConversionRateConfig value, + GroupedTieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -28842,67 +35081,83 @@ JsonSerializerOptions options } /// -/// Configuration for matrix_with_display_name pricing +/// Configuration for grouped_tiered_package pricing /// [JsonConverter( typeof(JsonModelConverter< - MatrixWithDisplayNameMatrixWithDisplayNameConfig, - MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + GroupedTieredPackageGroupedTieredPackageConfig, + GroupedTieredPackageGroupedTieredPackageConfigFromRaw >) )] -public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfig : JsonModel +public sealed record class GroupedTieredPackageGroupedTieredPackageConfig : JsonModel { /// - /// Used to determine the unit rate + /// The event property used to group before tiering /// - public required string Dimension + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("dimension"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("dimension", value); } + 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 per unit pricing to each dimension value + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. /// - public required IReadOnlyList UnitAmounts + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("unit_amounts"); + ImmutableArray + >("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("unit_amounts", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } /// public override void Validate() { - _ = this.Dimension; - foreach (var item in this.UnitAmounts) + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) { item.Validate(); } } - public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } + public GroupedTieredPackageGroupedTieredPackageConfig() { } - public MatrixWithDisplayNameMatrixWithDisplayNameConfig( - MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageGroupedTieredPackageConfig( + GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig ) - : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } + : base(groupedTieredPackageGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 - public MatrixWithDisplayNameMatrixWithDisplayNameConfig( + public GroupedTieredPackageGroupedTieredPackageConfig( IReadOnlyDictionary rawData ) { @@ -28911,14 +35166,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MatrixWithDisplayNameMatrixWithDisplayNameConfig(FrozenDictionary rawData) + GroupedTieredPackageGroupedTieredPackageConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + /// + public static GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -28926,81 +35181,67 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw - : IFromRawJson +class GroupedTieredPackageGroupedTieredPackageConfigFromRaw + : IFromRawJson { /// - public MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( + public GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked(rawData); + ) => GroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a unit amount item +/// Configuration for a single tier /// [JsonConverter( typeof(JsonModelConverter< - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + GroupedTieredPackageGroupedTieredPackageConfigTier, + GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw >) )] -public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount : JsonModel +public sealed record class GroupedTieredPackageGroupedTieredPackageConfigTier : 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 + /// Per package /// - public required string DisplayName + public required string PerUnit { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("display_name"); + return this._rawData.GetNotNullClass("per_unit"); } - init { this._rawData.Set("display_name", value); } + init { this._rawData.Set("per_unit", value); } } - /// - /// Per unit amount - /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.DimensionValue; - _ = this.DisplayName; - _ = this.UnitAmount; + _ = this.PerUnit; + _ = this.TierLowerBound; } - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } + public GroupedTieredPackageGroupedTieredPackageConfigTier() { } - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageGroupedTieredPackageConfigTier( + GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier ) - : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } + : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + public GroupedTieredPackageGroupedTieredPackageConfigTier( IReadOnlyDictionary rawData ) { @@ -29009,7 +35250,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + GroupedTieredPackageGroupedTieredPackageConfigTier( FrozenDictionary rawData ) { @@ -29017,8 +35258,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + /// + public static GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29026,26 +35267,26 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw - : IFromRawJson +class GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + : IFromRawJson { /// - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + public GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); + ) => GroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MatrixWithDisplayNamePriceTypeConverter))] -public enum MatrixWithDisplayNamePriceType +[JsonConverter(typeof(GroupedTieredPackagePriceTypeConverter))] +public enum GroupedTieredPackagePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class MatrixWithDisplayNamePriceTypeConverter : JsonConverter +sealed class GroupedTieredPackagePriceTypeConverter : JsonConverter { - public override MatrixWithDisplayNamePriceType Read( + public override GroupedTieredPackagePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29053,16 +35294,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => MatrixWithDisplayNamePriceType.UsagePrice, - "fixed_price" => MatrixWithDisplayNamePriceType.FixedPrice, - "composite_price" => MatrixWithDisplayNamePriceType.CompositePrice, - _ => (MatrixWithDisplayNamePriceType)(-1), + "usage_price" => GroupedTieredPackagePriceType.UsagePrice, + "fixed_price" => GroupedTieredPackagePriceType.FixedPrice, + "composite_price" => GroupedTieredPackagePriceType.CompositePrice, + _ => (GroupedTieredPackagePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNamePriceType value, + GroupedTieredPackagePriceType value, JsonSerializerOptions options ) { @@ -29070,9 +35311,9 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNamePriceType.UsagePrice => "usage_price", - MatrixWithDisplayNamePriceType.FixedPrice => "fixed_price", - MatrixWithDisplayNamePriceType.CompositePrice => "composite_price", + GroupedTieredPackagePriceType.UsagePrice => "usage_price", + GroupedTieredPackagePriceType.FixedPrice => "fixed_price", + GroupedTieredPackagePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29082,8 +35323,109 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class GroupedTieredPackage : 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< + 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 { public required string ID { @@ -29117,42 +35459,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -29169,12 +35511,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedTieredPackageConversionRateConfig? ConversionRateConfig + public required MaxGroupTieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -29242,19 +35584,14 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } - /// - /// Configuration for grouped_tiered_package pricing - /// - public required GroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig + public required string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_tiered_package_config" - ); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("grouped_tiered_package_config", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } public required BillingCycleConfiguration? InvoicingCycleConfiguration @@ -29282,6 +35619,21 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } + /// + /// Configuration for max_group_tiered_package pricing + /// + public required MaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_config", value); } + } + [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -29381,12 +35733,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -29419,6 +35771,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() { @@ -29439,9 +35806,10 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedTieredPackageConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); + this.MaxGroupTieredPackageConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -29450,7 +35818,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_tiered_package") + JsonSerializer.SerializeToElement("max_group_tiered_package") ) ) { @@ -29461,30 +35829,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 GroupedTieredPackage() + public MaxGroupTieredPackage() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + 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 GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) - : base(groupedTieredPackage) { } + public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) + : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedTieredPackage(IReadOnlyDictionary rawData) + public MaxGroupTieredPackage(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); } #pragma warning disable CS8618 @@ -29492,14 +35864,14 @@ public GroupedTieredPackage(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedTieredPackage(FrozenDictionary rawData) + MaxGroupTieredPackage(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackage FromRawUnchecked( + /// + public static MaxGroupTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29507,25 +35879,25 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageFromRaw : IFromRawJson +class MaxGroupTieredPackageFromRaw : IFromRawJson { /// - public GroupedTieredPackage FromRawUnchecked( + public MaxGroupTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackage.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedTieredPackageBillingModeConverter))] -public enum GroupedTieredPackageBillingMode +[JsonConverter(typeof(MaxGroupTieredPackageBillingModeConverter))] +public enum MaxGroupTieredPackageBillingMode { InAdvance, InArrear, } -sealed class GroupedTieredPackageBillingModeConverter - : JsonConverter +sealed class MaxGroupTieredPackageBillingModeConverter + : JsonConverter { - public override GroupedTieredPackageBillingMode Read( + public override MaxGroupTieredPackageBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29533,15 +35905,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedTieredPackageBillingMode.InAdvance, - "in_arrear" => GroupedTieredPackageBillingMode.InArrear, - _ => (GroupedTieredPackageBillingMode)(-1), + "in_advance" => MaxGroupTieredPackageBillingMode.InAdvance, + "in_arrear" => MaxGroupTieredPackageBillingMode.InArrear, + _ => (MaxGroupTieredPackageBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageBillingMode value, + MaxGroupTieredPackageBillingMode value, JsonSerializerOptions options ) { @@ -29549,8 +35921,8 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageBillingMode.InAdvance => "in_advance", - GroupedTieredPackageBillingMode.InArrear => "in_arrear", + MaxGroupTieredPackageBillingMode.InAdvance => "in_advance", + MaxGroupTieredPackageBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29560,8 +35932,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] -public enum GroupedTieredPackageCadence +[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] +public enum MaxGroupTieredPackageCadence { OneTime, Monthly, @@ -29571,9 +35943,9 @@ public enum GroupedTieredPackageCadence Custom, } -sealed class GroupedTieredPackageCadenceConverter : JsonConverter +sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter { - public override GroupedTieredPackageCadence Read( + public override MaxGroupTieredPackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29581,19 +35953,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedTieredPackageCadence.OneTime, - "monthly" => GroupedTieredPackageCadence.Monthly, - "quarterly" => GroupedTieredPackageCadence.Quarterly, - "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, - "annual" => GroupedTieredPackageCadence.Annual, - "custom" => GroupedTieredPackageCadence.Custom, - _ => (GroupedTieredPackageCadence)(-1), + "one_time" => MaxGroupTieredPackageCadence.OneTime, + "monthly" => MaxGroupTieredPackageCadence.Monthly, + "quarterly" => MaxGroupTieredPackageCadence.Quarterly, + "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, + "annual" => MaxGroupTieredPackageCadence.Annual, + "custom" => MaxGroupTieredPackageCadence.Custom, + _ => (MaxGroupTieredPackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCadence value, + MaxGroupTieredPackageCadence value, JsonSerializerOptions options ) { @@ -29601,12 +35973,12 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCadence.OneTime => "one_time", - GroupedTieredPackageCadence.Monthly => "monthly", - GroupedTieredPackageCadence.Quarterly => "quarterly", - GroupedTieredPackageCadence.SemiAnnual => "semi_annual", - GroupedTieredPackageCadence.Annual => "annual", - GroupedTieredPackageCadence.Custom => "custom", + MaxGroupTieredPackageCadence.OneTime => "one_time", + MaxGroupTieredPackageCadence.Monthly => "monthly", + MaxGroupTieredPackageCadence.Quarterly => "quarterly", + MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", + MaxGroupTieredPackageCadence.Annual => "annual", + MaxGroupTieredPackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29618,22 +35990,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageCompositePriceFilter, - GroupedTieredPackageCompositePriceFilterFromRaw + MaxGroupTieredPackageCompositePriceFilter, + MaxGroupTieredPackageCompositePriceFilterFromRaw >) )] -public sealed record class GroupedTieredPackageCompositePriceFilter : JsonModel +public sealed record class MaxGroupTieredPackageCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -29642,13 +36014,13 @@ public required ApiEnum F /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -29681,14 +36053,17 @@ public override void Validate() _ = this.Values; } - public GroupedTieredPackageCompositePriceFilter() { } + public MaxGroupTieredPackageCompositePriceFilter() { } - public GroupedTieredPackageCompositePriceFilter( - GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageCompositePriceFilter( + MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter ) - : base(groupedTieredPackageCompositePriceFilter) { } + : base(maxGroupTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 - public GroupedTieredPackageCompositePriceFilter( + public MaxGroupTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -29697,14 +36072,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageCompositePriceFilter(FrozenDictionary rawData) + MaxGroupTieredPackageCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageCompositePriceFilter FromRawUnchecked( + /// + public static MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29712,20 +36087,20 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageCompositePriceFilterFromRaw - : IFromRawJson +class MaxGroupTieredPackageCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedTieredPackageCompositePriceFilter FromRawUnchecked( + public MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterFieldConverter))] -public enum GroupedTieredPackageCompositePriceFilterField +[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterFieldConverter))] +public enum MaxGroupTieredPackageCompositePriceFilterField { PriceID, ItemID, @@ -29734,10 +36109,10 @@ public enum GroupedTieredPackageCompositePriceFilterField PricingUnitID, } -sealed class GroupedTieredPackageCompositePriceFilterFieldConverter - : JsonConverter +sealed class MaxGroupTieredPackageCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedTieredPackageCompositePriceFilterField Read( + public override MaxGroupTieredPackageCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29745,18 +36120,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => GroupedTieredPackageCompositePriceFilterField.PriceID, - "item_id" => GroupedTieredPackageCompositePriceFilterField.ItemID, - "price_type" => GroupedTieredPackageCompositePriceFilterField.PriceType, - "currency" => GroupedTieredPackageCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedTieredPackageCompositePriceFilterField.PricingUnitID, - _ => (GroupedTieredPackageCompositePriceFilterField)(-1), + "price_id" => MaxGroupTieredPackageCompositePriceFilterField.PriceID, + "item_id" => MaxGroupTieredPackageCompositePriceFilterField.ItemID, + "price_type" => MaxGroupTieredPackageCompositePriceFilterField.PriceType, + "currency" => MaxGroupTieredPackageCompositePriceFilterField.Currency, + "pricing_unit_id" => MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID, + _ => (MaxGroupTieredPackageCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCompositePriceFilterField value, + MaxGroupTieredPackageCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -29764,11 +36139,11 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCompositePriceFilterField.PriceID => "price_id", - GroupedTieredPackageCompositePriceFilterField.ItemID => "item_id", - GroupedTieredPackageCompositePriceFilterField.PriceType => "price_type", - GroupedTieredPackageCompositePriceFilterField.Currency => "currency", - GroupedTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + MaxGroupTieredPackageCompositePriceFilterField.PriceID => "price_id", + MaxGroupTieredPackageCompositePriceFilterField.ItemID => "item_id", + MaxGroupTieredPackageCompositePriceFilterField.PriceType => "price_type", + MaxGroupTieredPackageCompositePriceFilterField.Currency => "currency", + MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29781,17 +36156,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterOperatorConverter))] -public enum GroupedTieredPackageCompositePriceFilterOperator +[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterOperatorConverter))] +public enum MaxGroupTieredPackageCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedTieredPackageCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MaxGroupTieredPackageCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedTieredPackageCompositePriceFilterOperator Read( + public override MaxGroupTieredPackageCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29799,15 +36174,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedTieredPackageCompositePriceFilterOperator.Includes, - "excludes" => GroupedTieredPackageCompositePriceFilterOperator.Excludes, - _ => (GroupedTieredPackageCompositePriceFilterOperator)(-1), + "includes" => MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + "excludes" => MaxGroupTieredPackageCompositePriceFilterOperator.Excludes, + _ => (MaxGroupTieredPackageCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCompositePriceFilterOperator value, + MaxGroupTieredPackageCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -29815,8 +36190,8 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCompositePriceFilterOperator.Includes => "includes", - GroupedTieredPackageCompositePriceFilterOperator.Excludes => "excludes", + MaxGroupTieredPackageCompositePriceFilterOperator.Includes => "includes", + MaxGroupTieredPackageCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29826,8 +36201,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] -public record class GroupedTieredPackageConversionRateConfig : ModelBase +[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] +public record class MaxGroupTieredPackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -29844,7 +36219,7 @@ public JsonElement Json } } - public GroupedTieredPackageConversionRateConfig( + public MaxGroupTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -29853,7 +36228,7 @@ public GroupedTieredPackageConversionRateConfig( this._element = element; } - public GroupedTieredPackageConversionRateConfig( + public MaxGroupTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -29862,7 +36237,7 @@ public GroupedTieredPackageConversionRateConfig( this._element = element; } - public GroupedTieredPackageConversionRateConfig(JsonElement element) + public MaxGroupTieredPackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -29871,7 +36246,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 +36267,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 +36287,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 +36298,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -29944,7 +36319,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ); } } @@ -29953,7 +36328,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 +36339,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -29980,16 +36355,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ), }; } - public static implicit operator GroupedTieredPackageConversionRateConfig( + public static implicit operator MaxGroupTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedTieredPackageConversionRateConfig( + public static implicit operator MaxGroupTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -30008,16 +36383,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ); } 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(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -30025,13 +36400,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 GroupedTieredPackageConversionRateConfigConverter - : JsonConverter +sealed class MaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter { - public override GroupedTieredPackageConversionRateConfig? Read( + public override MaxGroupTieredPackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30060,12 +36448,10 @@ JsonSerializerOptions 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 +36468,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -30096,14 +36480,14 @@ JsonSerializerOptions options } default: { - return new GroupedTieredPackageConversionRateConfig(element); + return new MaxGroupTieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageConversionRateConfig value, + MaxGroupTieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -30112,18 +36496,18 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_tiered_package pricing +/// Configuration for max_group_tiered_package pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageGroupedTieredPackageConfig, - GroupedTieredPackageGroupedTieredPackageConfigFromRaw + MaxGroupTieredPackageMaxGroupTieredPackageConfig, + MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw >) )] -public sealed record class GroupedTieredPackageGroupedTieredPackageConfig : JsonModel +public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfig : JsonModel { /// - /// The event property used to group before tiering + /// The event property used to group before tiering the group with the highest value /// public required string GroupingKey { @@ -30146,21 +36530,20 @@ public required string PackageSize } /// - /// Apply tiered pricing after rounding up the quantity to the package size. - /// Tiers are defined using exclusive lower bounds. + /// 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 + ImmutableArray >("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -30178,14 +36561,17 @@ public override void Validate() } } - public GroupedTieredPackageGroupedTieredPackageConfig() { } + public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } - public GroupedTieredPackageGroupedTieredPackageConfig( - GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageMaxGroupTieredPackageConfig( + MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig ) - : base(groupedTieredPackageGroupedTieredPackageConfig) { } + : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 - public GroupedTieredPackageGroupedTieredPackageConfig( + public MaxGroupTieredPackageMaxGroupTieredPackageConfig( IReadOnlyDictionary rawData ) { @@ -30194,14 +36580,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageGroupedTieredPackageConfig(FrozenDictionary rawData) + MaxGroupTieredPackageMaxGroupTieredPackageConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + /// + public static MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30209,13 +36595,13 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageGroupedTieredPackageConfigFromRaw - : IFromRawJson +class MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + : IFromRawJson { /// - public GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + public MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked(rawData); } /// @@ -30223,50 +36609,53 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageGroupedTieredPackageConfigTier, - GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw >) )] -public sealed record class GroupedTieredPackageGroupedTieredPackageConfigTier : JsonModel +public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfigTier : JsonModel { - /// - /// Per package - /// - public required string PerUnit + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("per_unit", value); } + init { this._rawData.Set("tier_lower_bound", value); } } - public required string TierLowerBound + /// + /// Per unit amount + /// + 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); } } /// public override void Validate() { - _ = this.PerUnit; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public GroupedTieredPackageGroupedTieredPackageConfigTier() { } + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } - public GroupedTieredPackageGroupedTieredPackageConfigTier( - GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier ) - : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } + : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 - public GroupedTieredPackageGroupedTieredPackageConfigTier( + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( IReadOnlyDictionary rawData ) { @@ -30275,7 +36664,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageGroupedTieredPackageConfigTier( + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( FrozenDictionary rawData ) { @@ -30283,8 +36672,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + /// + public static MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30292,26 +36681,26 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw - : IFromRawJson +class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + : IFromRawJson { /// - public GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedTieredPackagePriceTypeConverter))] -public enum GroupedTieredPackagePriceType +[JsonConverter(typeof(MaxGroupTieredPackagePriceTypeConverter))] +public enum MaxGroupTieredPackagePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class GroupedTieredPackagePriceTypeConverter : JsonConverter +sealed class MaxGroupTieredPackagePriceTypeConverter : JsonConverter { - public override GroupedTieredPackagePriceType Read( + public override MaxGroupTieredPackagePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30319,16 +36708,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => GroupedTieredPackagePriceType.UsagePrice, - "fixed_price" => GroupedTieredPackagePriceType.FixedPrice, - "composite_price" => GroupedTieredPackagePriceType.CompositePrice, - _ => (GroupedTieredPackagePriceType)(-1), + "usage_price" => MaxGroupTieredPackagePriceType.UsagePrice, + "fixed_price" => MaxGroupTieredPackagePriceType.FixedPrice, + "composite_price" => MaxGroupTieredPackagePriceType.CompositePrice, + _ => (MaxGroupTieredPackagePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackagePriceType value, + MaxGroupTieredPackagePriceType value, JsonSerializerOptions options ) { @@ -30336,9 +36725,9 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackagePriceType.UsagePrice => "usage_price", - GroupedTieredPackagePriceType.FixedPrice => "fixed_price", - GroupedTieredPackagePriceType.CompositePrice => "composite_price", + MaxGroupTieredPackagePriceType.UsagePrice => "usage_price", + MaxGroupTieredPackagePriceType.FixedPrice => "fixed_price", + MaxGroupTieredPackagePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30348,8 +36737,111 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MaxGroupTieredPackage : 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< + 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) +)] +public sealed record class ScalableMatrixWithUnitPricing : JsonModel { public required string ID { @@ -30383,42 +36875,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) ); @@ -30435,12 +36927,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required MaxGroupTieredPackageConversionRateConfig? ConversionRateConfig + public required ScalableMatrixWithUnitPricingConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -30508,6 +37000,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -30533,21 +37035,6 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } - /// - /// Configuration for max_group_tiered_package pricing - /// - public required MaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "max_group_tiered_package_config" - ); - } - init { this._rawData.Set("max_group_tiered_package_config", value); } - } - [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -30647,14 +37134,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); } } @@ -30673,6 +37160,21 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } + /// + /// Configuration for scalable_matrix_with_unit_pricing pricing + /// + public required ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "scalable_matrix_with_unit_pricing_config" + ); + } + init { this._rawData.Set("scalable_matrix_with_unit_pricing_config", value); } + } + public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get @@ -30685,6 +37187,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() { @@ -30705,9 +37224,9 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); - this.MaxGroupTieredPackageConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -30716,7 +37235,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("max_group_tiered_package") + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") ) ) { @@ -30726,31 +37245,38 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; + this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MaxGroupTieredPackage() + public ScalableMatrixWithUnitPricing() { - this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + 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" )] - public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) - : base(maxGroupTieredPackage) { } + public ScalableMatrixWithUnitPricing( + ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing + ) + : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MaxGroupTieredPackage(IReadOnlyDictionary rawData) + public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); } #pragma warning disable CS8618 @@ -30758,14 +37284,14 @@ public MaxGroupTieredPackage(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - MaxGroupTieredPackage(FrozenDictionary rawData) + ScalableMatrixWithUnitPricing(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackage FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricing FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30773,25 +37299,25 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageFromRaw : IFromRawJson +class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson { /// - public MaxGroupTieredPackage FromRawUnchecked( + public ScalableMatrixWithUnitPricing FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); + ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MaxGroupTieredPackageBillingModeConverter))] -public enum MaxGroupTieredPackageBillingMode +[JsonConverter(typeof(ScalableMatrixWithUnitPricingBillingModeConverter))] +public enum ScalableMatrixWithUnitPricingBillingMode { InAdvance, InArrear, } -sealed class MaxGroupTieredPackageBillingModeConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingBillingModeConverter + : JsonConverter { - public override MaxGroupTieredPackageBillingMode Read( + public override ScalableMatrixWithUnitPricingBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30799,15 +37325,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => MaxGroupTieredPackageBillingMode.InAdvance, - "in_arrear" => MaxGroupTieredPackageBillingMode.InArrear, - _ => (MaxGroupTieredPackageBillingMode)(-1), + "in_advance" => ScalableMatrixWithUnitPricingBillingMode.InAdvance, + "in_arrear" => ScalableMatrixWithUnitPricingBillingMode.InArrear, + _ => (ScalableMatrixWithUnitPricingBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageBillingMode value, + ScalableMatrixWithUnitPricingBillingMode value, JsonSerializerOptions options ) { @@ -30815,8 +37341,8 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageBillingMode.InAdvance => "in_advance", - MaxGroupTieredPackageBillingMode.InArrear => "in_arrear", + ScalableMatrixWithUnitPricingBillingMode.InAdvance => "in_advance", + ScalableMatrixWithUnitPricingBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30826,8 +37352,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] -public enum MaxGroupTieredPackageCadence +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] +public enum ScalableMatrixWithUnitPricingCadence { OneTime, Monthly, @@ -30837,9 +37363,10 @@ public enum MaxGroupTieredPackageCadence Custom, } -sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter +sealed class ScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter { - public override MaxGroupTieredPackageCadence Read( + public override ScalableMatrixWithUnitPricingCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30847,19 +37374,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => MaxGroupTieredPackageCadence.OneTime, - "monthly" => MaxGroupTieredPackageCadence.Monthly, - "quarterly" => MaxGroupTieredPackageCadence.Quarterly, - "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, - "annual" => MaxGroupTieredPackageCadence.Annual, - "custom" => MaxGroupTieredPackageCadence.Custom, - _ => (MaxGroupTieredPackageCadence)(-1), + "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, + "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, + "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, + "annual" => ScalableMatrixWithUnitPricingCadence.Annual, + "custom" => ScalableMatrixWithUnitPricingCadence.Custom, + _ => (ScalableMatrixWithUnitPricingCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCadence value, + ScalableMatrixWithUnitPricingCadence value, JsonSerializerOptions options ) { @@ -30867,12 +37394,12 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCadence.OneTime => "one_time", - MaxGroupTieredPackageCadence.Monthly => "monthly", - MaxGroupTieredPackageCadence.Quarterly => "quarterly", - MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", - MaxGroupTieredPackageCadence.Annual => "annual", - MaxGroupTieredPackageCadence.Custom => "custom", + ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", + ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", + ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithUnitPricingCadence.Annual => "annual", + ScalableMatrixWithUnitPricingCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30884,22 +37411,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageCompositePriceFilter, - MaxGroupTieredPackageCompositePriceFilterFromRaw + ScalableMatrixWithUnitPricingCompositePriceFilter, + ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw >) )] -public sealed record class MaxGroupTieredPackageCompositePriceFilter : JsonModel +public sealed record class ScalableMatrixWithUnitPricingCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -30908,13 +37435,16 @@ public required ApiEnum /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + ScalableMatrixWithUnitPricingCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -30947,14 +37477,17 @@ public override void Validate() _ = this.Values; } - public MaxGroupTieredPackageCompositePriceFilter() { } + public ScalableMatrixWithUnitPricingCompositePriceFilter() { } - public MaxGroupTieredPackageCompositePriceFilter( - MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingCompositePriceFilter( + ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter ) - : base(maxGroupTieredPackageCompositePriceFilter) { } + : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } +#pragma warning restore CS8618 - public MaxGroupTieredPackageCompositePriceFilter( + public ScalableMatrixWithUnitPricingCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -30963,14 +37496,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageCompositePriceFilter(FrozenDictionary rawData) + ScalableMatrixWithUnitPricingCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30978,20 +37511,20 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageCompositePriceFilterFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( + public ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); + ) => ScalableMatrixWithUnitPricingCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterFieldConverter))] -public enum MaxGroupTieredPackageCompositePriceFilterField +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter))] +public enum ScalableMatrixWithUnitPricingCompositePriceFilterField { PriceID, ItemID, @@ -31000,10 +37533,10 @@ public enum MaxGroupTieredPackageCompositePriceFilterField PricingUnitID, } -sealed class MaxGroupTieredPackageCompositePriceFilterFieldConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter + : JsonConverter { - public override MaxGroupTieredPackageCompositePriceFilterField Read( + public override ScalableMatrixWithUnitPricingCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31011,18 +37544,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => MaxGroupTieredPackageCompositePriceFilterField.PriceID, - "item_id" => MaxGroupTieredPackageCompositePriceFilterField.ItemID, - "price_type" => MaxGroupTieredPackageCompositePriceFilterField.PriceType, - "currency" => MaxGroupTieredPackageCompositePriceFilterField.Currency, - "pricing_unit_id" => MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID, - _ => (MaxGroupTieredPackageCompositePriceFilterField)(-1), + "price_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + "item_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID, + "price_type" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType, + "currency" => ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency, + "pricing_unit_id" => + ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID, + _ => (ScalableMatrixWithUnitPricingCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCompositePriceFilterField value, + ScalableMatrixWithUnitPricingCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -31030,11 +37564,12 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCompositePriceFilterField.PriceID => "price_id", - MaxGroupTieredPackageCompositePriceFilterField.ItemID => "item_id", - MaxGroupTieredPackageCompositePriceFilterField.PriceType => "price_type", - MaxGroupTieredPackageCompositePriceFilterField.Currency => "currency", - MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID => "price_id", + ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID => "item_id", + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType => "price_type", + ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency => "currency", + ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -31047,17 +37582,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterOperatorConverter))] -public enum MaxGroupTieredPackageCompositePriceFilterOperator +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter))] +public enum ScalableMatrixWithUnitPricingCompositePriceFilterOperator { Includes, Excludes, } -sealed class MaxGroupTieredPackageCompositePriceFilterOperatorConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter + : JsonConverter { - public override MaxGroupTieredPackageCompositePriceFilterOperator Read( + public override ScalableMatrixWithUnitPricingCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31065,15 +37600,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => MaxGroupTieredPackageCompositePriceFilterOperator.Includes, - "excludes" => MaxGroupTieredPackageCompositePriceFilterOperator.Excludes, - _ => (MaxGroupTieredPackageCompositePriceFilterOperator)(-1), + "includes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + "excludes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes, + _ => (ScalableMatrixWithUnitPricingCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCompositePriceFilterOperator value, + ScalableMatrixWithUnitPricingCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -31081,8 +37616,8 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCompositePriceFilterOperator.Includes => "includes", - MaxGroupTieredPackageCompositePriceFilterOperator.Excludes => "excludes", + ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes => "includes", + ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -31092,8 +37627,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] -public record class MaxGroupTieredPackageConversionRateConfig : ModelBase +[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -31110,7 +37645,7 @@ public JsonElement Json } } - public MaxGroupTieredPackageConversionRateConfig( + public ScalableMatrixWithUnitPricingConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -31119,7 +37654,7 @@ public MaxGroupTieredPackageConversionRateConfig( this._element = element; } - public MaxGroupTieredPackageConversionRateConfig( + public ScalableMatrixWithUnitPricingConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -31128,7 +37663,7 @@ public MaxGroupTieredPackageConversionRateConfig( this._element = element; } - public MaxGroupTieredPackageConversionRateConfig(JsonElement element) + public ScalableMatrixWithUnitPricingConversionRateConfig(JsonElement element) { this._element = element; } @@ -31137,7 +37672,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 +37693,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 +37713,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 +37724,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31210,7 +37745,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ); } } @@ -31219,7 +37754,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 +37765,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31246,16 +37781,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ), }; } - public static implicit operator MaxGroupTieredPackageConversionRateConfig( + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MaxGroupTieredPackageConversionRateConfig( + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -31274,16 +37809,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ); } 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(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -31291,13 +37826,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 MaxGroupTieredPackageConversionRateConfigConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter { - public override MaxGroupTieredPackageConversionRateConfig? Read( + public override ScalableMatrixWithUnitPricingConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31326,12 +37874,10 @@ JsonSerializerOptions 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 +37894,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -31362,14 +37906,14 @@ JsonSerializerOptions options } default: { - return new MaxGroupTieredPackageConversionRateConfig(element); + return new ScalableMatrixWithUnitPricingConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageConversionRateConfig value, + ScalableMatrixWithUnitPricingConversionRateConfig value, JsonSerializerOptions options ) { @@ -31377,80 +37921,176 @@ JsonSerializerOptions options } } +[JsonConverter(typeof(ScalableMatrixWithUnitPricingPriceTypeConverter))] +public enum ScalableMatrixWithUnitPricingPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class ScalableMatrixWithUnitPricingPriceTypeConverter + : JsonConverter +{ + public override ScalableMatrixWithUnitPricingPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => ScalableMatrixWithUnitPricingPriceType.UsagePrice, + "fixed_price" => ScalableMatrixWithUnitPricingPriceType.FixedPrice, + "composite_price" => ScalableMatrixWithUnitPricingPriceType.CompositePrice, + _ => (ScalableMatrixWithUnitPricingPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithUnitPricingPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithUnitPricingPriceType.UsagePrice => "usage_price", + ScalableMatrixWithUnitPricingPriceType.FixedPrice => "fixed_price", + ScalableMatrixWithUnitPricingPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + /// -/// Configuration for max_group_tiered_package pricing +/// Configuration for scalable_matrix_with_unit_pricing pricing /// [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageMaxGroupTieredPackageConfig, - MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw >) )] -public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfig : JsonModel +public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + : JsonModel { /// - /// The event property used to group before tiering the group with the highest value + /// 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 GroupingKey + public required string UnitPrice { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("unit_price"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("unit_price", value); } } - public required string PackageSize + /// + /// The property used to group this price + /// + public string? GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("package_size"); + return this._rawData.GetNullableClass("grouping_key"); } - init { this._rawData.Set("package_size", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// Apply tiered pricing to the largest group after grouping with the provided key. + /// If true, the unit price will be prorated to the billing period /// - public required IReadOnlyList Tiers + public bool? Prorate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNullableStruct("prorate"); } - init + init { this._rawData.Set("prorate", value); } + } + + /// + /// Used to determine the unit rate (optional) + /// + public string? SecondDimension + { + get { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); } + init { this._rawData.Set("second_dimension", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.PackageSize; - foreach (var item in this.Tiers) + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) { item.Validate(); } + _ = this.UnitPrice; + _ = this.GroupingKey; + _ = this.Prorate; + _ = this.SecondDimension; } - public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfig( - MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ) - : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } + : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 - public MaxGroupTieredPackageMaxGroupTieredPackageConfig( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData ) { @@ -31459,14 +38099,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageMaxGroupTieredPackageConfig(FrozenDictionary rawData) + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -31474,64 +38116,77 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked(rawData); + ) => ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single tier +/// Configuration for a single matrix scaling factor /// [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier, - MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw >) )] -public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfigTier : JsonModel +public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + : JsonModel { - public required string TierLowerBound + public required string FirstDimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("first_dimension_value"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("first_dimension_value", value); } } - /// - /// Per unit amount - /// - public required string UnitAmount + public required string ScalingFactor { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("scaling_factor"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; } - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) - : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } + : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) + { } +#pragma warning restore CS8618 - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData ) { @@ -31540,7 +38195,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( FrozenDictionary rawData ) { @@ -31548,8 +38203,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -31557,66 +38212,129 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(MaxGroupTieredPackagePriceTypeConverter))] -public enum MaxGroupTieredPackagePriceType +/// +/// 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 { - UsagePrice, - FixedPrice, - CompositePrice, -} + /// + /// 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); } + } -sealed class MaxGroupTieredPackagePriceTypeConverter : JsonConverter -{ - public override MaxGroupTieredPackagePriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "usage_price" => MaxGroupTieredPackagePriceType.UsagePrice, - "fixed_price" => MaxGroupTieredPackagePriceType.FixedPrice, - "composite_price" => MaxGroupTieredPackagePriceType.CompositePrice, - _ => (MaxGroupTieredPackagePriceType)(-1), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } - public override void Write( - Utf8JsonWriter writer, - MaxGroupTieredPackagePriceType value, - JsonSerializerOptions options + /// + /// 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 ) { - JsonSerializer.Serialize( - writer, - value switch - { - MaxGroupTieredPackagePriceType.UsagePrice => "usage_price", - MaxGroupTieredPackagePriceType.FixedPrice => "fixed_price", - MaxGroupTieredPackagePriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + 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) + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricing, + ScalableMatrixWithTieredPricingFromRaw + >) )] -public sealed record class ScalableMatrixWithUnitPricing : JsonModel +public sealed record class ScalableMatrixWithTieredPricing : JsonModel { public required string ID { @@ -31650,42 +38368,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -31702,12 +38420,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required ScalableMatrixWithUnitPricingConversionRateConfig? ConversionRateConfig + public required ScalableMatrixWithTieredPricingConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -31775,6 +38493,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -31899,13 +38627,13 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("price_type"); } init { this._rawData.Set("price_type", value); } @@ -31926,18 +38654,18 @@ public required string? ReplacesPriceID } /// - /// Configuration for scalable_matrix_with_unit_pricing pricing + /// Configuration for scalable_matrix_with_tiered_pricing pricing /// - public required ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig + public required ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "scalable_matrix_with_unit_pricing_config" + return this._rawData.GetNotNullClass( + "scalable_matrix_with_tiered_pricing_config" ); } - init { this._rawData.Set("scalable_matrix_with_unit_pricing_config", value); } + init { this._rawData.Set("scalable_matrix_with_tiered_pricing_config", value); } } public DimensionalPriceConfiguration? DimensionalPriceConfiguration @@ -31952,6 +38680,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() { @@ -31972,6 +38717,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -31982,7 +38728,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") ) ) { @@ -31992,34 +38738,38 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.ScalableMatrixWithUnitPricingConfig.Validate(); + this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithUnitPricing() + public ScalableMatrixWithTieredPricing() { - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + 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" )] - public ScalableMatrixWithUnitPricing( - ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing + public ScalableMatrixWithTieredPricing( + ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing ) - : base(scalableMatrixWithUnitPricing) { } + : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) + public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); } #pragma warning disable CS8618 @@ -32027,14 +38777,14 @@ public ScalableMatrixWithUnitPricing(IReadOnlyDictionary ra "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - ScalableMatrixWithUnitPricing(FrozenDictionary rawData) + ScalableMatrixWithTieredPricing(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricing FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricing FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32042,25 +38792,25 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson +class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson { /// - public ScalableMatrixWithUnitPricing FromRawUnchecked( + public ScalableMatrixWithTieredPricing FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); + ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingBillingModeConverter))] -public enum ScalableMatrixWithUnitPricingBillingMode +[JsonConverter(typeof(ScalableMatrixWithTieredPricingBillingModeConverter))] +public enum ScalableMatrixWithTieredPricingBillingMode { InAdvance, InArrear, } -sealed class ScalableMatrixWithUnitPricingBillingModeConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingBillingModeConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingBillingMode Read( + public override ScalableMatrixWithTieredPricingBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32068,15 +38818,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => ScalableMatrixWithUnitPricingBillingMode.InAdvance, - "in_arrear" => ScalableMatrixWithUnitPricingBillingMode.InArrear, - _ => (ScalableMatrixWithUnitPricingBillingMode)(-1), + "in_advance" => ScalableMatrixWithTieredPricingBillingMode.InAdvance, + "in_arrear" => ScalableMatrixWithTieredPricingBillingMode.InArrear, + _ => (ScalableMatrixWithTieredPricingBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingBillingMode value, + ScalableMatrixWithTieredPricingBillingMode value, JsonSerializerOptions options ) { @@ -32084,8 +38834,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingBillingMode.InAdvance => "in_advance", - ScalableMatrixWithUnitPricingBillingMode.InArrear => "in_arrear", + ScalableMatrixWithTieredPricingBillingMode.InAdvance => "in_advance", + ScalableMatrixWithTieredPricingBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32095,8 +38845,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] -public enum ScalableMatrixWithUnitPricingCadence +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] +public enum ScalableMatrixWithTieredPricingCadence { OneTime, Monthly, @@ -32106,10 +38856,10 @@ public enum ScalableMatrixWithUnitPricingCadence Custom, } -sealed class ScalableMatrixWithUnitPricingCadenceConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingCadence Read( + public override ScalableMatrixWithTieredPricingCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32117,19 +38867,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, - "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, - "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, - "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, - "annual" => ScalableMatrixWithUnitPricingCadence.Annual, - "custom" => ScalableMatrixWithUnitPricingCadence.Custom, - _ => (ScalableMatrixWithUnitPricingCadence)(-1), + "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, + "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, + "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, + "annual" => ScalableMatrixWithTieredPricingCadence.Annual, + "custom" => ScalableMatrixWithTieredPricingCadence.Custom, + _ => (ScalableMatrixWithTieredPricingCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCadence value, + ScalableMatrixWithTieredPricingCadence value, JsonSerializerOptions options ) { @@ -32137,12 +38887,12 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", - ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", - ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", - ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", - ScalableMatrixWithUnitPricingCadence.Annual => "annual", - ScalableMatrixWithUnitPricingCadence.Custom => "custom", + ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", + ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", + ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithTieredPricingCadence.Annual => "annual", + ScalableMatrixWithTieredPricingCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32154,22 +38904,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingCompositePriceFilter, - ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw + ScalableMatrixWithTieredPricingCompositePriceFilter, + ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingCompositePriceFilter : JsonModel +public sealed record class ScalableMatrixWithTieredPricingCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -32180,14 +38930,14 @@ public required ApiEnum public required ApiEnum< string, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator + ScalableMatrixWithTieredPricingCompositePriceFilterOperator > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -32220,14 +38970,17 @@ public override void Validate() _ = this.Values; } - public ScalableMatrixWithUnitPricingCompositePriceFilter() { } + public ScalableMatrixWithTieredPricingCompositePriceFilter() { } - public ScalableMatrixWithUnitPricingCompositePriceFilter( - ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingCompositePriceFilter( + ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter ) - : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } + : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } +#pragma warning restore CS8618 - public ScalableMatrixWithUnitPricingCompositePriceFilter( + public ScalableMatrixWithTieredPricingCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -32236,14 +38989,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingCompositePriceFilter(FrozenDictionary rawData) + ScalableMatrixWithTieredPricingCompositePriceFilter( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32251,20 +39006,20 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( + public ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricingCompositePriceFilter.FromRawUnchecked(rawData); + ) => ScalableMatrixWithTieredPricingCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter))] -public enum ScalableMatrixWithUnitPricingCompositePriceFilterField +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter))] +public enum ScalableMatrixWithTieredPricingCompositePriceFilterField { PriceID, ItemID, @@ -32273,10 +39028,10 @@ public enum ScalableMatrixWithUnitPricingCompositePriceFilterField PricingUnitID, } -sealed class ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingCompositePriceFilterField Read( + public override ScalableMatrixWithTieredPricingCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32284,19 +39039,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - "item_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID, - "price_type" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType, - "currency" => ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency, + "price_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + "item_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID, + "price_type" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType, + "currency" => ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency, "pricing_unit_id" => - ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID, - _ => (ScalableMatrixWithUnitPricingCompositePriceFilterField)(-1), + ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID, + _ => (ScalableMatrixWithTieredPricingCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCompositePriceFilterField value, + ScalableMatrixWithTieredPricingCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -32304,11 +39059,11 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID => "price_id", - ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID => "item_id", - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType => "price_type", - ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency => "currency", - ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID => + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID => "price_id", + ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID => "item_id", + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType => "price_type", + ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency => "currency", + ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -32322,17 +39077,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter))] -public enum ScalableMatrixWithUnitPricingCompositePriceFilterOperator +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter))] +public enum ScalableMatrixWithTieredPricingCompositePriceFilterOperator { Includes, Excludes, } -sealed class ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingCompositePriceFilterOperator Read( + public override ScalableMatrixWithTieredPricingCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32340,15 +39095,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, - "excludes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes, - _ => (ScalableMatrixWithUnitPricingCompositePriceFilterOperator)(-1), + "includes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + "excludes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes, + _ => (ScalableMatrixWithTieredPricingCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator value, + ScalableMatrixWithTieredPricingCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -32356,8 +39111,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes => "includes", - ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes => "excludes", + ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes => "includes", + ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32367,8 +39122,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] -public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase +[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -32385,7 +39140,7 @@ public JsonElement Json } } - public ScalableMatrixWithUnitPricingConversionRateConfig( + public ScalableMatrixWithTieredPricingConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -32394,7 +39149,7 @@ public ScalableMatrixWithUnitPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithUnitPricingConversionRateConfig( + public ScalableMatrixWithTieredPricingConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -32403,7 +39158,7 @@ public ScalableMatrixWithUnitPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithUnitPricingConversionRateConfig(JsonElement element) + public ScalableMatrixWithTieredPricingConversionRateConfig(JsonElement element) { this._element = element; } @@ -32412,7 +39167,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 +39188,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 +39208,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 +39219,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32485,7 +39240,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ); } } @@ -32494,7 +39249,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 +39260,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32521,16 +39276,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ), }; } - public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -32549,16 +39304,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ); } 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(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -32566,13 +39321,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 ScalableMatrixWithUnitPricingConversionRateConfigConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingConversionRateConfig? Read( + public override ScalableMatrixWithTieredPricingConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32601,12 +39369,10 @@ JsonSerializerOptions 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 +39389,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -32637,14 +39401,14 @@ JsonSerializerOptions options } default: { - return new ScalableMatrixWithUnitPricingConversionRateConfig(element); + return new ScalableMatrixWithTieredPricingConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingConversionRateConfig value, + ScalableMatrixWithTieredPricingConversionRateConfig value, JsonSerializerOptions options ) { @@ -32652,18 +39416,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingPriceTypeConverter))] -public enum ScalableMatrixWithUnitPricingPriceType +[JsonConverter(typeof(ScalableMatrixWithTieredPricingPriceTypeConverter))] +public enum ScalableMatrixWithTieredPricingPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class ScalableMatrixWithUnitPricingPriceTypeConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingPriceTypeConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingPriceType Read( + public override ScalableMatrixWithTieredPricingPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32671,16 +39435,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => ScalableMatrixWithUnitPricingPriceType.UsagePrice, - "fixed_price" => ScalableMatrixWithUnitPricingPriceType.FixedPrice, - "composite_price" => ScalableMatrixWithUnitPricingPriceType.CompositePrice, - _ => (ScalableMatrixWithUnitPricingPriceType)(-1), + "usage_price" => ScalableMatrixWithTieredPricingPriceType.UsagePrice, + "fixed_price" => ScalableMatrixWithTieredPricingPriceType.FixedPrice, + "composite_price" => ScalableMatrixWithTieredPricingPriceType.CompositePrice, + _ => (ScalableMatrixWithTieredPricingPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingPriceType value, + ScalableMatrixWithTieredPricingPriceType value, JsonSerializerOptions options ) { @@ -32688,9 +39452,9 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingPriceType.UsagePrice => "usage_price", - ScalableMatrixWithUnitPricingPriceType.FixedPrice => "fixed_price", - ScalableMatrixWithUnitPricingPriceType.CompositePrice => "composite_price", + ScalableMatrixWithTieredPricingPriceType.UsagePrice => "usage_price", + ScalableMatrixWithTieredPricingPriceType.FixedPrice => "fixed_price", + ScalableMatrixWithTieredPricingPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32701,19 +39465,19 @@ JsonSerializerOptions options } /// -/// Configuration for scalable_matrix_with_unit_pricing pricing +/// Configuration for scalable_matrix_with_tiered_pricing pricing /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig : JsonModel { /// - /// Used to determine the unit rate + /// Used for the scalable matrix first dimension /// public required string FirstDimension { @@ -32728,51 +39492,42 @@ 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)); } } - /// - /// The final unit price to rate against the output of the matrix - /// - public required string UnitPrice + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_price"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("unit_price", value); } - } - - /// - /// If true, the unit price will be prorated to the billing period - /// - public bool? Prorate - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorate"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("prorate", value); } } /// - /// Used to determine the unit rate (optional) + /// Used for the scalable matrix second dimension (optional) /// public string? SecondDimension { @@ -32792,19 +39547,24 @@ public override void Validate() { item.Validate(); } - _ = this.UnitPrice; - _ = this.Prorate; + foreach (var item in this.Tiers) + { + item.Validate(); + } _ = this.SecondDimension; } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ) - : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } + : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( IReadOnlyDictionary rawData ) { @@ -32813,7 +39573,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( FrozenDictionary rawData ) { @@ -32821,8 +39581,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32830,13 +39590,16 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); + ) => + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( + rawData + ); } /// @@ -32844,11 +39607,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor : JsonModel { public required string FirstDimensionValue @@ -32889,15 +39652,20 @@ public override void Validate() _ = this.SecondDimensionValue; } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() + { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) - : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) - { } + : base( + scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) { } +#pragma warning restore CS8618 - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData ) { @@ -32906,7 +39674,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( FrozenDictionary rawData ) { @@ -32914,8 +39682,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32923,25 +39691,211 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) => - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( rawData ); } +/// +/// Configuration for a single tier entry with business logic +/// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricing, - ScalableMatrixWithTieredPricingFromRaw + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricing : JsonModel +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + : JsonModel +{ + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) + : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// 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 { public required string ID { @@ -32975,42 +39929,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); + return this._rawData.GetNotNullClass>( + "billing_mode" + ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -33027,12 +39981,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required ScalableMatrixWithTieredPricingConversionRateConfig? ConversionRateConfig + public required CumulativeGroupedBulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -33059,6 +40013,21 @@ public required Allocation? CreditAllocation init { this._rawData.Set("credit_allocation", value); } } + /// + /// Configuration for cumulative_grouped_bulk pricing + /// + public required CumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" + ); + } + init { this._rawData.Set("cumulative_grouped_bulk_config", value); } + } + public required string Currency { get @@ -33100,6 +40069,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -33224,14 +40203,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); + return this._rawData.GetNotNullClass>( + "price_type" + ); } init { this._rawData.Set("price_type", value); } } @@ -33250,31 +40229,31 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } - /// - /// Configuration for scalable_matrix_with_tiered_pricing pricing - /// - public required ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig + public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "scalable_matrix_with_tiered_pricing_config" + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } - init { this._rawData.Set("scalable_matrix_with_tiered_pricing_config", value); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public DimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// 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( - "dimensional_price_configuration" - ); + return this._rawData.GetNullableClass("license_type"); } - init { this._rawData.Set("dimensional_price_configuration", value); } + init { this._rawData.Set("license_type", value); } } /// @@ -33293,10 +40272,12 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); + this.CumulativeGroupedBulkConfig.Validate(); _ = this.Currency; this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -33307,7 +40288,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") ) ) { @@ -33317,34 +40298,35 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithTieredPricing() + public CumulativeGroupedBulk() { - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + 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 ScalableMatrixWithTieredPricing( - ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing - ) - : base(scalableMatrixWithTieredPricing) { } + public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) + : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) + public CumulativeGroupedBulk(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); } #pragma warning disable CS8618 @@ -33352,14 +40334,14 @@ public ScalableMatrixWithTieredPricing(IReadOnlyDictionary "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - ScalableMatrixWithTieredPricing(FrozenDictionary rawData) + CumulativeGroupedBulk(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricing FromRawUnchecked( + /// + public static CumulativeGroupedBulk FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -33367,25 +40349,25 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson +class CumulativeGroupedBulkFromRaw : IFromRawJson { /// - public ScalableMatrixWithTieredPricing FromRawUnchecked( + public CumulativeGroupedBulk FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingBillingModeConverter))] -public enum ScalableMatrixWithTieredPricingBillingMode +[JsonConverter(typeof(CumulativeGroupedBulkBillingModeConverter))] +public enum CumulativeGroupedBulkBillingMode { InAdvance, InArrear, } -sealed class ScalableMatrixWithTieredPricingBillingModeConverter - : JsonConverter +sealed class CumulativeGroupedBulkBillingModeConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingBillingMode Read( + public override CumulativeGroupedBulkBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33393,15 +40375,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => ScalableMatrixWithTieredPricingBillingMode.InAdvance, - "in_arrear" => ScalableMatrixWithTieredPricingBillingMode.InArrear, - _ => (ScalableMatrixWithTieredPricingBillingMode)(-1), + "in_advance" => CumulativeGroupedBulkBillingMode.InAdvance, + "in_arrear" => CumulativeGroupedBulkBillingMode.InArrear, + _ => (CumulativeGroupedBulkBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingBillingMode value, + CumulativeGroupedBulkBillingMode value, JsonSerializerOptions options ) { @@ -33409,8 +40391,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingBillingMode.InAdvance => "in_advance", - ScalableMatrixWithTieredPricingBillingMode.InArrear => "in_arrear", + CumulativeGroupedBulkBillingMode.InAdvance => "in_advance", + CumulativeGroupedBulkBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33420,8 +40402,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] -public enum ScalableMatrixWithTieredPricingCadence +[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] +public enum CumulativeGroupedBulkCadence { OneTime, Monthly, @@ -33431,10 +40413,9 @@ public enum ScalableMatrixWithTieredPricingCadence Custom, } -sealed class ScalableMatrixWithTieredPricingCadenceConverter - : JsonConverter +sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter { - public override ScalableMatrixWithTieredPricingCadence Read( + public override CumulativeGroupedBulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33442,32 +40423,32 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, - "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, - "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, - "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, - "annual" => ScalableMatrixWithTieredPricingCadence.Annual, - "custom" => ScalableMatrixWithTieredPricingCadence.Custom, - _ => (ScalableMatrixWithTieredPricingCadence)(-1), + "one_time" => CumulativeGroupedBulkCadence.OneTime, + "monthly" => CumulativeGroupedBulkCadence.Monthly, + "quarterly" => CumulativeGroupedBulkCadence.Quarterly, + "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, + "annual" => CumulativeGroupedBulkCadence.Annual, + "custom" => CumulativeGroupedBulkCadence.Custom, + _ => (CumulativeGroupedBulkCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCadence value, + CumulativeGroupedBulkCadence value, JsonSerializerOptions options ) { JsonSerializer.Serialize( writer, - value switch - { - ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", - ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", - ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", - ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", - ScalableMatrixWithTieredPricingCadence.Annual => "annual", - ScalableMatrixWithTieredPricingCadence.Custom => "custom", + value switch + { + CumulativeGroupedBulkCadence.OneTime => "one_time", + CumulativeGroupedBulkCadence.Monthly => "monthly", + CumulativeGroupedBulkCadence.Quarterly => "quarterly", + CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", + CumulativeGroupedBulkCadence.Annual => "annual", + CumulativeGroupedBulkCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33479,22 +40460,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingCompositePriceFilter, - ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw + CumulativeGroupedBulkCompositePriceFilter, + CumulativeGroupedBulkCompositePriceFilterFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingCompositePriceFilter : JsonModel +public sealed record class CumulativeGroupedBulkCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -33503,16 +40484,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum< - string, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator - > Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -33545,14 +40523,17 @@ public override void Validate() _ = this.Values; } - public ScalableMatrixWithTieredPricingCompositePriceFilter() { } + public CumulativeGroupedBulkCompositePriceFilter() { } - public ScalableMatrixWithTieredPricingCompositePriceFilter( - ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkCompositePriceFilter( + CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter ) - : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } + : base(cumulativeGroupedBulkCompositePriceFilter) { } +#pragma warning restore CS8618 - public ScalableMatrixWithTieredPricingCompositePriceFilter( + public CumulativeGroupedBulkCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -33561,16 +40542,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingCompositePriceFilter( - FrozenDictionary rawData - ) + CumulativeGroupedBulkCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( + /// + public static CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -33578,20 +40557,20 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw - : IFromRawJson +class CumulativeGroupedBulkCompositePriceFilterFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( + public CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithTieredPricingCompositePriceFilter.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulkCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter))] -public enum ScalableMatrixWithTieredPricingCompositePriceFilterField +[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterFieldConverter))] +public enum CumulativeGroupedBulkCompositePriceFilterField { PriceID, ItemID, @@ -33600,10 +40579,10 @@ public enum ScalableMatrixWithTieredPricingCompositePriceFilterField PricingUnitID, } -sealed class ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter - : JsonConverter +sealed class CumulativeGroupedBulkCompositePriceFilterFieldConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingCompositePriceFilterField Read( + public override CumulativeGroupedBulkCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33611,19 +40590,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - "item_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID, - "price_type" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType, - "currency" => ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency, - "pricing_unit_id" => - ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID, - _ => (ScalableMatrixWithTieredPricingCompositePriceFilterField)(-1), + "price_id" => CumulativeGroupedBulkCompositePriceFilterField.PriceID, + "item_id" => CumulativeGroupedBulkCompositePriceFilterField.ItemID, + "price_type" => CumulativeGroupedBulkCompositePriceFilterField.PriceType, + "currency" => CumulativeGroupedBulkCompositePriceFilterField.Currency, + "pricing_unit_id" => CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID, + _ => (CumulativeGroupedBulkCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCompositePriceFilterField value, + CumulativeGroupedBulkCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -33631,12 +40609,11 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID => "price_id", - ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID => "item_id", - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType => "price_type", - ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency => "currency", - ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", + CumulativeGroupedBulkCompositePriceFilterField.PriceID => "price_id", + CumulativeGroupedBulkCompositePriceFilterField.ItemID => "item_id", + CumulativeGroupedBulkCompositePriceFilterField.PriceType => "price_type", + CumulativeGroupedBulkCompositePriceFilterField.Currency => "currency", + CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33649,17 +40626,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter))] -public enum ScalableMatrixWithTieredPricingCompositePriceFilterOperator +[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterOperatorConverter))] +public enum CumulativeGroupedBulkCompositePriceFilterOperator { Includes, Excludes, } -sealed class ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter - : JsonConverter +sealed class CumulativeGroupedBulkCompositePriceFilterOperatorConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingCompositePriceFilterOperator Read( + public override CumulativeGroupedBulkCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33667,15 +40644,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, - "excludes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes, - _ => (ScalableMatrixWithTieredPricingCompositePriceFilterOperator)(-1), + "includes" => CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + "excludes" => CumulativeGroupedBulkCompositePriceFilterOperator.Excludes, + _ => (CumulativeGroupedBulkCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator value, + CumulativeGroupedBulkCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -33683,8 +40660,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes => "includes", - ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes => "excludes", + CumulativeGroupedBulkCompositePriceFilterOperator.Includes => "includes", + CumulativeGroupedBulkCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33694,8 +40671,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] -public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] +public record class CumulativeGroupedBulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -33712,7 +40689,7 @@ public JsonElement Json } } - public ScalableMatrixWithTieredPricingConversionRateConfig( + public CumulativeGroupedBulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -33721,7 +40698,7 @@ public ScalableMatrixWithTieredPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithTieredPricingConversionRateConfig( + public CumulativeGroupedBulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -33730,7 +40707,7 @@ public ScalableMatrixWithTieredPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithTieredPricingConversionRateConfig(JsonElement element) + public CumulativeGroupedBulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -33739,7 +40716,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 +40737,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 +40757,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 +40768,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33812,7 +40789,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } } @@ -33821,7 +40798,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 +40809,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33848,16 +40825,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ), }; } - public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + public static implicit operator CumulativeGroupedBulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + public static implicit operator CumulativeGroupedBulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -33876,16 +40853,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } 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(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -33893,13 +40870,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 ScalableMatrixWithTieredPricingConversionRateConfigConverter - : JsonConverter +sealed class CumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingConversionRateConfig? Read( + public override CumulativeGroupedBulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33928,12 +40918,10 @@ JsonSerializerOptions 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 +40938,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -33964,14 +40950,14 @@ JsonSerializerOptions options } default: { - return new ScalableMatrixWithTieredPricingConversionRateConfig(element); + return new CumulativeGroupedBulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingConversionRateConfig value, + CumulativeGroupedBulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -33979,152 +40965,68 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingPriceTypeConverter))] -public enum ScalableMatrixWithTieredPricingPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class ScalableMatrixWithTieredPricingPriceTypeConverter - : JsonConverter -{ - public override ScalableMatrixWithTieredPricingPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => ScalableMatrixWithTieredPricingPriceType.UsagePrice, - "fixed_price" => ScalableMatrixWithTieredPricingPriceType.FixedPrice, - "composite_price" => ScalableMatrixWithTieredPricingPriceType.CompositePrice, - _ => (ScalableMatrixWithTieredPricingPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ScalableMatrixWithTieredPricingPriceType.UsagePrice => "usage_price", - ScalableMatrixWithTieredPricingPriceType.FixedPrice => "fixed_price", - ScalableMatrixWithTieredPricingPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - /// -/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// Configuration for cumulative_grouped_bulk pricing /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + CumulativeGroupedBulkCumulativeGroupedBulkConfig, + CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig - : JsonModel +public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfig : 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 + /// Each tier lower bound must have the same group of values. /// - 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 + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + ImmutableArray + >("dimension_values"); } init { this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + ImmutableArray + >("dimension_values", ImmutableArray.ToImmutableArray(value)); } } - /// - /// Used for the scalable matrix second dimension (optional) - /// - public string? SecondDimension + public required string Group { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("second_dimension"); + return this._rawData.GetNotNullClass("group"); } - init { this._rawData.Set("second_dimension", value); } + init { this._rawData.Set("group", value); } } /// public override void Validate() { - _ = this.FirstDimension; - foreach (var item in this.MatrixScalingFactors) - { - item.Validate(); - } - foreach (var item in this.Tiers) + foreach (var item in this.DimensionValues) { item.Validate(); } - _ = this.SecondDimension; + _ = this.Group; } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } + public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkCumulativeGroupedBulkConfig( + CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig ) - : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + public CumulativeGroupedBulkCumulativeGroupedBulkConfig( IReadOnlyDictionary rawData ) { @@ -34133,16 +41035,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( - FrozenDictionary rawData - ) + CumulativeGroupedBulkCumulativeGroupedBulkConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + /// + public static CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34150,79 +41050,85 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw - : IFromRawJson +class CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + public CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single matrix scaling factor +/// Configuration for a dimension value entry /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor +public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue : JsonModel { - public required string FirstDimensionValue + /// + /// Grouping key value + /// + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("first_dimension_value"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("first_dimension_value", value); } + init { this._rawData.Set("grouping_key", value); } } - public required string ScalingFactor + /// + /// Tier lower bound + /// + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("scaling_factor"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("scaling_factor", value); } + init { this._rawData.Set("tier_lower_bound", value); } } - public string? SecondDimensionValue + /// + /// Unit amount for this combination + /// + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("second_dimension_value"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("second_dimension_value", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.FirstDimensionValue; - _ = this.ScalingFactor; - _ = this.SecondDimensionValue; + _ = this.GroupingKey; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() - { } + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue ) - : base( - scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - ) { } + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } +#pragma warning restore CS8618 - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( IReadOnlyDictionary rawData ) { @@ -34231,7 +41137,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( FrozenDictionary rawData ) { @@ -34239,8 +41145,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34248,83 +41154,148 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw - : IFromRawJson +class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( - 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 ); + } } /// -/// Configuration for a single tier entry with business logic +/// 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< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + CumulativeGroupedBulkLicenseType, + CumulativeGroupedBulkLicenseTypeFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier - : JsonModel +public sealed record class CumulativeGroupedBulkLicenseType : JsonModel { - public required string TierLowerBound + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("id"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("id", value); } } - public required string UnitAmount + /// + /// 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("unit_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } + public CumulativeGroupedBulkLicenseType() { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseType( + CumulativeGroupedBulkLicenseType cumulativeGroupedBulkLicenseType ) - : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } + : base(cumulativeGroupedBulkLicenseType) { } +#pragma warning restore CS8618 - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - IReadOnlyDictionary rawData - ) + public CumulativeGroupedBulkLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - FrozenDictionary rawData - ) + CumulativeGroupedBulkLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + /// + public static CumulativeGroupedBulkLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34332,20 +41303,18 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw - : IFromRawJson +class CumulativeGroupedBulkLicenseTypeFromRaw : IFromRawJson { /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + public CumulativeGroupedBulkLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedBulkLicenseType.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class CumulativeGroupedBulk : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedAllocation : JsonModel { public required string ID { @@ -34379,42 +41348,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "billing_mode" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -34431,12 +41400,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required CumulativeGroupedBulkConversionRateConfig? ConversionRateConfig + public required CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -34464,18 +41433,18 @@ public required Allocation? CreditAllocation } /// - /// Configuration for cumulative_grouped_bulk pricing + /// Configuration for cumulative_grouped_allocation pricing /// - public required CumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_bulk_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("cumulative_grouped_bulk_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } public required string Currency @@ -34519,6 +41488,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -34643,14 +41622,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); } } @@ -34681,6 +41660,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() { @@ -34697,11 +41693,12 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); - this.CumulativeGroupedBulkConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -34712,7 +41709,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -34723,30 +41720,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 CumulativeGroupedBulk() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + 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 CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) - : base(cumulativeGroupedBulk) { } + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedBulk(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 @@ -34754,14 +41755,14 @@ public CumulativeGroupedBulk(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - CumulativeGroupedBulk(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulk FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34769,25 +41770,25 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public CumulativeGroupedBulk FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedBulkBillingModeConverter))] -public enum CumulativeGroupedBulkBillingMode +[JsonConverter(typeof(CumulativeGroupedAllocationBillingModeConverter))] +public enum CumulativeGroupedAllocationBillingMode { InAdvance, InArrear, } -sealed class CumulativeGroupedBulkBillingModeConverter - : JsonConverter +sealed class CumulativeGroupedAllocationBillingModeConverter + : JsonConverter { - public override CumulativeGroupedBulkBillingMode Read( + public override CumulativeGroupedAllocationBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -34795,15 +41796,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => CumulativeGroupedBulkBillingMode.InAdvance, - "in_arrear" => CumulativeGroupedBulkBillingMode.InArrear, - _ => (CumulativeGroupedBulkBillingMode)(-1), + "in_advance" => CumulativeGroupedAllocationBillingMode.InAdvance, + "in_arrear" => CumulativeGroupedAllocationBillingMode.InArrear, + _ => (CumulativeGroupedAllocationBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkBillingMode value, + CumulativeGroupedAllocationBillingMode value, JsonSerializerOptions options ) { @@ -34811,8 +41812,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkBillingMode.InAdvance => "in_advance", - CumulativeGroupedBulkBillingMode.InArrear => "in_arrear", + CumulativeGroupedAllocationBillingMode.InAdvance => "in_advance", + CumulativeGroupedAllocationBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -34822,8 +41823,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] -public enum CumulativeGroupedBulkCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { OneTime, Monthly, @@ -34833,9 +41834,10 @@ public enum CumulativeGroupedBulkCadence Custom, } -sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override CumulativeGroupedBulkCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -34843,19 +41845,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => CumulativeGroupedBulkCadence.OneTime, - "monthly" => CumulativeGroupedBulkCadence.Monthly, - "quarterly" => CumulativeGroupedBulkCadence.Quarterly, - "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, - "annual" => CumulativeGroupedBulkCadence.Annual, - "custom" => CumulativeGroupedBulkCadence.Custom, - _ => (CumulativeGroupedBulkCadence)(-1), + "one_time" => 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, - CumulativeGroupedBulkCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -34863,12 +41865,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCadence.OneTime => "one_time", - CumulativeGroupedBulkCadence.Monthly => "monthly", - CumulativeGroupedBulkCadence.Quarterly => "quarterly", - CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", - CumulativeGroupedBulkCadence.Annual => "annual", - CumulativeGroupedBulkCadence.Custom => "custom", + 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)) ), @@ -34880,22 +41882,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedBulkCompositePriceFilter, - CumulativeGroupedBulkCompositePriceFilterFromRaw + CumulativeGroupedAllocationCompositePriceFilter, + CumulativeGroupedAllocationCompositePriceFilterFromRaw >) )] -public sealed record class CumulativeGroupedBulkCompositePriceFilter : 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); } @@ -34904,13 +41906,16 @@ public required ApiEnum /// /// 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); } @@ -34943,14 +41948,17 @@ public override void Validate() _ = this.Values; } - public CumulativeGroupedBulkCompositePriceFilter() { } + public CumulativeGroupedAllocationCompositePriceFilter() { } - public CumulativeGroupedBulkCompositePriceFilter( - CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationCompositePriceFilter( + CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter ) - : base(cumulativeGroupedBulkCompositePriceFilter) { } + : base(cumulativeGroupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 - public CumulativeGroupedBulkCompositePriceFilter( + public CumulativeGroupedAllocationCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -34959,14 +41967,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedBulkCompositePriceFilter(FrozenDictionary rawData) + CumulativeGroupedAllocationCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( + /// + public static CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34974,20 +41982,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCompositePriceFilterFromRaw - : IFromRawJson +class CumulativeGroupedAllocationCompositePriceFilterFromRaw + : IFromRawJson { /// - public CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( + public CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCompositePriceFilter.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterFieldConverter))] -public enum CumulativeGroupedBulkCompositePriceFilterField +[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterFieldConverter))] +public enum CumulativeGroupedAllocationCompositePriceFilterField { PriceID, ItemID, @@ -34996,10 +42004,10 @@ public enum CumulativeGroupedBulkCompositePriceFilterField PricingUnitID, } -sealed class CumulativeGroupedBulkCompositePriceFilterFieldConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCompositePriceFilterFieldConverter + : JsonConverter { - public override CumulativeGroupedBulkCompositePriceFilterField Read( + public override CumulativeGroupedAllocationCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35007,18 +42015,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => CumulativeGroupedBulkCompositePriceFilterField.PriceID, - "item_id" => CumulativeGroupedBulkCompositePriceFilterField.ItemID, - "price_type" => CumulativeGroupedBulkCompositePriceFilterField.PriceType, - "currency" => CumulativeGroupedBulkCompositePriceFilterField.Currency, - "pricing_unit_id" => CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID, - _ => (CumulativeGroupedBulkCompositePriceFilterField)(-1), + "price_id" => 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, - CumulativeGroupedBulkCompositePriceFilterField value, + CumulativeGroupedAllocationCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -35026,11 +42034,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCompositePriceFilterField.PriceID => "price_id", - CumulativeGroupedBulkCompositePriceFilterField.ItemID => "item_id", - CumulativeGroupedBulkCompositePriceFilterField.PriceType => "price_type", - CumulativeGroupedBulkCompositePriceFilterField.Currency => "currency", - CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + 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)) ), @@ -35043,17 +42052,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterOperatorConverter))] -public enum CumulativeGroupedBulkCompositePriceFilterOperator +[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterOperatorConverter))] +public enum CumulativeGroupedAllocationCompositePriceFilterOperator { Includes, Excludes, } -sealed class CumulativeGroupedBulkCompositePriceFilterOperatorConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCompositePriceFilterOperatorConverter + : JsonConverter { - public override CumulativeGroupedBulkCompositePriceFilterOperator Read( + public override CumulativeGroupedAllocationCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35061,15 +42070,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => CumulativeGroupedBulkCompositePriceFilterOperator.Includes, - "excludes" => CumulativeGroupedBulkCompositePriceFilterOperator.Excludes, - _ => (CumulativeGroupedBulkCompositePriceFilterOperator)(-1), + "includes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + "excludes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes, + _ => (CumulativeGroupedAllocationCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkCompositePriceFilterOperator value, + CumulativeGroupedAllocationCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -35077,8 +42086,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCompositePriceFilterOperator.Includes => "includes", - CumulativeGroupedBulkCompositePriceFilterOperator.Excludes => "excludes", + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes => "includes", + CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -35088,8 +42097,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] -public record class CumulativeGroupedBulkConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -35106,7 +42115,7 @@ public JsonElement Json } } - public CumulativeGroupedBulkConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -35115,7 +42124,7 @@ public CumulativeGroupedBulkConversionRateConfig( this._element = element; } - public CumulativeGroupedBulkConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -35124,7 +42133,7 @@ public CumulativeGroupedBulkConversionRateConfig( this._element = element; } - public CumulativeGroupedBulkConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -35133,7 +42142,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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -35154,7 +42163,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. /// /// /// @@ -35174,7 +42183,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. /// /// @@ -35185,8 +42194,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -35206,7 +42215,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -35215,7 +42224,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. /// /// @@ -35226,8 +42235,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -35242,16 +42251,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedBulkConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedBulkConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -35270,16 +42279,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -35287,13 +42296,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 CumulativeGroupedBulkConversionRateConfigConverter - : JsonConverter +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedBulkConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35322,12 +42344,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -35344,12 +42364,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -35358,14 +42376,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedBulkConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -35374,80 +42392,102 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_bulk pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedBulkCumulativeGroupedBulkConfig, - CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfig : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// Each tier lower bound must have the same group of values. + /// The overall allocation across all groups /// - public required IReadOnlyList DimensionValues + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("dimension_values"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get { - this._rawData.Set< - ImmutableArray - >("dimension_values", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); } + init { this._rawData.Set("group_allocation", value); } } - public required string Group + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("group", value); } + init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount { - foreach (var item in this.DimensionValues) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } - _ = this.Group; + init { this._rawData.Set("unit_amount", value); } } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } + /// + public override void Validate() + { + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig( - CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig - ) - : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } + public CumulativeGroupedAllocationConfig() { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig( - IReadOnlyDictionary rawData +#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] - CumulativeGroupedBulkCumulativeGroupedBulkConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -35455,100 +42495,148 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(CumulativeGroupedAllocationPriceTypeConverter))] +public enum CumulativeGroupedAllocationPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class CumulativeGroupedAllocationPriceTypeConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => CumulativeGroupedAllocationPriceType.UsagePrice, + "fixed_price" => CumulativeGroupedAllocationPriceType.FixedPrice, + "composite_price" => CumulativeGroupedAllocationPriceType.CompositePrice, + _ => (CumulativeGroupedAllocationPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } } /// -/// Configuration for a dimension value entry +/// 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< - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + CumulativeGroupedAllocationLicenseType, + CumulativeGroupedAllocationLicenseTypeFromRaw >) )] -public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue - : JsonModel +public sealed record class CumulativeGroupedAllocationLicenseType : JsonModel { /// - /// Grouping key value + /// The Orb-assigned unique identifier for the license type. /// - public required string GroupingKey + public required string ID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("id"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("id", value); } } /// - /// Tier lower bound + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. /// - public required string TierLowerBound + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// Unit amount for this combination + /// The name of the license type. /// - public required string UnitAmount + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("name", value); } } /// public override void Validate() { + _ = this.ID; _ = this.GroupingKey; - _ = this.TierLowerBound; - _ = this.UnitAmount; + _ = this.Name; } - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } + public CumulativeGroupedAllocationLicenseType() { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseType( + CumulativeGroupedAllocationLicenseType cumulativeGroupedAllocationLicenseType ) - : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } + : base(cumulativeGroupedAllocationLicenseType) { } +#pragma warning restore CS8618 - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - IReadOnlyDictionary rawData - ) + public CumulativeGroupedAllocationLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - FrozenDictionary rawData - ) + CumulativeGroupedAllocationLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + /// + public static CumulativeGroupedAllocationLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -35556,66 +42644,17 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw - : IFromRawJson +class CumulativeGroupedAllocationLicenseTypeFromRaw + : IFromRawJson { /// - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + public CumulativeGroupedAllocationLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(CumulativeGroupedBulkPriceTypeConverter))] -public enum CumulativeGroupedBulkPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, + ) => CumulativeGroupedAllocationLicenseType.FromRawUnchecked(rawData); } -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 +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : JsonModel { public required string ID { @@ -35649,42 +42688,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); + return this._rawData.GetNotNullClass>( + "billing_mode" + ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -35701,12 +42740,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public required DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -35733,29 +42772,29 @@ public required Allocation? CreditAllocation init { this._rawData.Set("credit_allocation", value); } } - /// - /// Configuration for cumulative_grouped_allocation pricing - /// - public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("currency", value); } } - public required string Currency + /// + /// Configuration for daily_credit_allowance pricing + /// + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } [System::Obsolete("deprecated")] @@ -35789,6 +42828,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -35913,14 +42962,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); + return this._rawData.GetNotNullClass>( + "price_type" + ); } init { this._rawData.Set("price_type", value); } } @@ -35951,6 +43000,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 DailyCreditAllowanceLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -35967,11 +43031,12 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -35982,7 +43047,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -35993,30 +43058,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 CumulativeGroupedAllocation() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 @@ -36024,14 +43093,14 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocation FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36039,25 +43108,25 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocation FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedAllocationBillingModeConverter))] -public enum CumulativeGroupedAllocationBillingMode +[JsonConverter(typeof(DailyCreditAllowanceBillingModeConverter))] +public enum DailyCreditAllowanceBillingMode { InAdvance, InArrear, } -sealed class CumulativeGroupedAllocationBillingModeConverter - : JsonConverter +sealed class DailyCreditAllowanceBillingModeConverter + : JsonConverter { - public override CumulativeGroupedAllocationBillingMode Read( + public override DailyCreditAllowanceBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36065,15 +43134,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => CumulativeGroupedAllocationBillingMode.InAdvance, - "in_arrear" => CumulativeGroupedAllocationBillingMode.InArrear, - _ => (CumulativeGroupedAllocationBillingMode)(-1), + "in_advance" => DailyCreditAllowanceBillingMode.InAdvance, + "in_arrear" => DailyCreditAllowanceBillingMode.InArrear, + _ => (DailyCreditAllowanceBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationBillingMode value, + DailyCreditAllowanceBillingMode value, JsonSerializerOptions options ) { @@ -36081,8 +43150,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationBillingMode.InAdvance => "in_advance", - CumulativeGroupedAllocationBillingMode.InArrear => "in_arrear", + DailyCreditAllowanceBillingMode.InAdvance => "in_advance", + DailyCreditAllowanceBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36092,8 +43161,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { OneTime, Monthly, @@ -36103,10 +43172,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override CumulativeGroupedAllocationCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36114,19 +43182,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => CumulativeGroupedAllocationCadence.OneTime, - "monthly" => CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, - "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, - "annual" => CumulativeGroupedAllocationCadence.Annual, - "custom" => CumulativeGroupedAllocationCadence.Custom, - _ => (CumulativeGroupedAllocationCadence)(-1), + "one_time" => DailyCreditAllowanceCadence.OneTime, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "annual" => DailyCreditAllowanceCadence.Annual, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -36134,12 +43202,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCadence.OneTime => "one_time", - CumulativeGroupedAllocationCadence.Monthly => "monthly", - CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - CumulativeGroupedAllocationCadence.Annual => "annual", - CumulativeGroupedAllocationCadence.Custom => "custom", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36151,22 +43219,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationCompositePriceFilter, - CumulativeGroupedAllocationCompositePriceFilterFromRaw + DailyCreditAllowanceCompositePriceFilter, + DailyCreditAllowanceCompositePriceFilterFromRaw >) )] -public sealed record class CumulativeGroupedAllocationCompositePriceFilter : JsonModel +public sealed record class DailyCreditAllowanceCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -36175,16 +43243,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum< - string, - CumulativeGroupedAllocationCompositePriceFilterOperator - > Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -36217,14 +43282,17 @@ public override void Validate() _ = this.Values; } - public CumulativeGroupedAllocationCompositePriceFilter() { } + public DailyCreditAllowanceCompositePriceFilter() { } - public CumulativeGroupedAllocationCompositePriceFilter( - CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceCompositePriceFilter( + DailyCreditAllowanceCompositePriceFilter dailyCreditAllowanceCompositePriceFilter ) - : base(cumulativeGroupedAllocationCompositePriceFilter) { } + : base(dailyCreditAllowanceCompositePriceFilter) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationCompositePriceFilter( + public DailyCreditAllowanceCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -36233,14 +43301,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationCompositePriceFilter(FrozenDictionary rawData) + DailyCreditAllowanceCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( + /// + public static DailyCreditAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36248,20 +43316,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationCompositePriceFilterFromRaw - : IFromRawJson +class DailyCreditAllowanceCompositePriceFilterFromRaw + : IFromRawJson { /// - public CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( + public DailyCreditAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterFieldConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterField +[JsonConverter(typeof(DailyCreditAllowanceCompositePriceFilterFieldConverter))] +public enum DailyCreditAllowanceCompositePriceFilterField { PriceID, ItemID, @@ -36270,10 +43338,10 @@ public enum CumulativeGroupedAllocationCompositePriceFilterField PricingUnitID, } -sealed class CumulativeGroupedAllocationCompositePriceFilterFieldConverter - : JsonConverter +sealed class DailyCreditAllowanceCompositePriceFilterFieldConverter + : JsonConverter { - public override CumulativeGroupedAllocationCompositePriceFilterField Read( + public override DailyCreditAllowanceCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36281,18 +43349,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - "item_id" => CumulativeGroupedAllocationCompositePriceFilterField.ItemID, - "price_type" => CumulativeGroupedAllocationCompositePriceFilterField.PriceType, - "currency" => CumulativeGroupedAllocationCompositePriceFilterField.Currency, - "pricing_unit_id" => CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID, - _ => (CumulativeGroupedAllocationCompositePriceFilterField)(-1), + "price_id" => DailyCreditAllowanceCompositePriceFilterField.PriceID, + "item_id" => DailyCreditAllowanceCompositePriceFilterField.ItemID, + "price_type" => DailyCreditAllowanceCompositePriceFilterField.PriceType, + "currency" => DailyCreditAllowanceCompositePriceFilterField.Currency, + "pricing_unit_id" => DailyCreditAllowanceCompositePriceFilterField.PricingUnitID, + _ => (DailyCreditAllowanceCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterField value, + DailyCreditAllowanceCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -36300,12 +43368,11 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCompositePriceFilterField.PriceID => "price_id", - CumulativeGroupedAllocationCompositePriceFilterField.ItemID => "item_id", - CumulativeGroupedAllocationCompositePriceFilterField.PriceType => "price_type", - CumulativeGroupedAllocationCompositePriceFilterField.Currency => "currency", - CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", + DailyCreditAllowanceCompositePriceFilterField.PriceID => "price_id", + DailyCreditAllowanceCompositePriceFilterField.ItemID => "item_id", + DailyCreditAllowanceCompositePriceFilterField.PriceType => "price_type", + DailyCreditAllowanceCompositePriceFilterField.Currency => "currency", + DailyCreditAllowanceCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36318,17 +43385,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterOperatorConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterOperator +[JsonConverter(typeof(DailyCreditAllowanceCompositePriceFilterOperatorConverter))] +public enum DailyCreditAllowanceCompositePriceFilterOperator { Includes, Excludes, } -sealed class CumulativeGroupedAllocationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class DailyCreditAllowanceCompositePriceFilterOperatorConverter + : JsonConverter { - public override CumulativeGroupedAllocationCompositePriceFilterOperator Read( + public override DailyCreditAllowanceCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36336,15 +43403,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - "excludes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes, - _ => (CumulativeGroupedAllocationCompositePriceFilterOperator)(-1), + "includes" => DailyCreditAllowanceCompositePriceFilterOperator.Includes, + "excludes" => DailyCreditAllowanceCompositePriceFilterOperator.Excludes, + _ => (DailyCreditAllowanceCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterOperator value, + DailyCreditAllowanceCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -36352,8 +43419,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes => "includes", - CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", + DailyCreditAllowanceCompositePriceFilterOperator.Includes => "includes", + DailyCreditAllowanceCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36363,8 +43430,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -36381,7 +43448,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -36390,7 +43457,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -36399,7 +43466,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -36408,7 +43475,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. /// /// /// @@ -36429,7 +43496,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 +43516,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 +43527,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36481,7 +43548,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -36490,7 +43557,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 +43568,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36517,16 +43584,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -36545,16 +43612,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -36562,13 +43629,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedAllocationConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36597,12 +43677,10 @@ JsonSerializerOptions 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 +43697,10 @@ JsonSerializerOptions 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 +43709,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedAllocationConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -36649,44 +43725,313 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class DailyCreditAllowanceConfig : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public DailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceConfigFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationConfig, - CumulativeGroupedAllocationConfigFromRaw + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class DailyCreditAllowanceConfigMatrixValue : JsonModel { /// - /// The overall allocation across all groups + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string CumulativeAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The allocation per individual group + /// Credits charged per unit of usage matching the specified dimension_values /// - public required string GroupAllocation + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.DimensionValues; + _ = this.UnitAmount; + } + + public DailyCreditAllowanceConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue + ) + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); } +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(DailyCreditAllowancePriceTypeConverter))] +public enum DailyCreditAllowancePriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class DailyCreditAllowancePriceTypeConverter : JsonConverter +{ + public override DailyCreditAllowancePriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => DailyCreditAllowancePriceType.UsagePrice, + "fixed_price" => DailyCreditAllowancePriceType.FixedPrice, + "composite_price" => DailyCreditAllowancePriceType.CompositePrice, + _ => (DailyCreditAllowancePriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + DailyCreditAllowancePriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + DailyCreditAllowancePriceType.UsagePrice => "usage_price", + DailyCreditAllowancePriceType.FixedPrice => "fixed_price", + DailyCreditAllowancePriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + 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< + DailyCreditAllowanceLicenseType, + DailyCreditAllowanceLicenseTypeFromRaw + >) +)] +public sealed record class DailyCreditAllowanceLicenseType : JsonModel +{ /// - /// The event property used to group usage before applying allocations + /// 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 { @@ -36699,49 +44044,51 @@ public required string GroupingKey } /// - /// The amount to charge for each unit outside of the allocation + /// The name of the license type. /// - public required string UnitAmount + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("name", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; + _ = this.ID; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.Name; } - public CumulativeGroupedAllocationConfig() { } + public DailyCreditAllowanceLicenseType() { } - public CumulativeGroupedAllocationConfig( - CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceLicenseType( + DailyCreditAllowanceLicenseType dailyCreditAllowanceLicenseType ) - : base(cumulativeGroupedAllocationConfig) { } + : base(dailyCreditAllowanceLicenseType) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + DailyCreditAllowanceLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceLicenseType FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36749,64 +44096,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +class DailyCreditAllowanceLicenseTypeFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocationConfig FromRawUnchecked( + public DailyCreditAllowanceLicenseType FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(CumulativeGroupedAllocationPriceTypeConverter))] -public enum CumulativeGroupedAllocationPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class CumulativeGroupedAllocationPriceTypeConverter - : JsonConverter -{ - public override CumulativeGroupedAllocationPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => CumulativeGroupedAllocationPriceType.UsagePrice, - "fixed_price" => CumulativeGroupedAllocationPriceType.FixedPrice, - "composite_price" => CumulativeGroupedAllocationPriceType.CompositePrice, - _ => (CumulativeGroupedAllocationPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedAllocationPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } + ) => DailyCreditAllowanceLicenseType.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceMinimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : JsonModel { public required string ID { @@ -36840,40 +44139,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -36890,12 +44191,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required PriceMinimumConversionRateConfig? ConversionRateConfig + public required MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -36963,6 +44264,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -37032,39 +44343,41 @@ public required IReadOnlyDictionary Metadata } } - [System::Obsolete("deprecated")] - public required Minimum? Minimum + /// + /// Configuration for metered_allowance pricing + /// + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("minimum", value); } + init { this._rawData.Set("metered_allowance_config", value); } } [System::Obsolete("deprecated")] - public required string? MinimumAmount + public required Minimum? Minimum { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); + return this._rawData.GetNullableClass("minimum"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("minimum", value); } } - /// - /// Configuration for minimum pricing - /// - public required MinimumConfig MinimumConfig + [System::Obsolete("deprecated")] + public required string? MinimumAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); + return this._rawData.GetNullableClass("minimum_amount"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("minimum_amount", value); } } /// @@ -37100,12 +44413,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -37138,6 +44451,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 MeteredAllowanceLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -37158,15 +44486,21 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; + this.MeteredAllowanceConfig.Validate(); this.Minimum?.Validate(); _ = this.MinimumAmount; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -37175,30 +44509,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 MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } +#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 MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public PriceMinimum(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 @@ -37206,36 +44544,38 @@ public PriceMinimum(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static MeteredAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PriceMinimumFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceMinimum.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceMinimumBillingModeConverter))] -public enum PriceMinimumBillingMode +[JsonConverter(typeof(MeteredAllowanceBillingModeConverter))] +public enum MeteredAllowanceBillingMode { InAdvance, InArrear, } -sealed class PriceMinimumBillingModeConverter : JsonConverter +sealed class MeteredAllowanceBillingModeConverter : JsonConverter { - public override PriceMinimumBillingMode Read( + public override MeteredAllowanceBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37243,15 +44583,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => PriceMinimumBillingMode.InAdvance, - "in_arrear" => PriceMinimumBillingMode.InArrear, - _ => (PriceMinimumBillingMode)(-1), + "in_advance" => MeteredAllowanceBillingMode.InAdvance, + "in_arrear" => MeteredAllowanceBillingMode.InArrear, + _ => (MeteredAllowanceBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumBillingMode value, + MeteredAllowanceBillingMode value, JsonSerializerOptions options ) { @@ -37259,8 +44599,8 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumBillingMode.InAdvance => "in_advance", - PriceMinimumBillingMode.InArrear => "in_arrear", + MeteredAllowanceBillingMode.InAdvance => "in_advance", + MeteredAllowanceBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37270,8 +44610,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { OneTime, Monthly, @@ -37281,9 +44621,9 @@ public enum PriceMinimumCadence Custom, } -sealed class PriceMinimumCadenceConverter : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override PriceMinimumCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37291,19 +44631,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" => MeteredAllowanceCadence.OneTime, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "annual" => MeteredAllowanceCadence.Annual, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -37311,12 +44651,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", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37328,22 +44668,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceMinimumCompositePriceFilter, - PriceMinimumCompositePriceFilterFromRaw + MeteredAllowanceCompositePriceFilter, + MeteredAllowanceCompositePriceFilterFromRaw >) )] -public sealed record class PriceMinimumCompositePriceFilter : JsonModel +public sealed record class MeteredAllowanceCompositePriceFilter : 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 +44692,13 @@ public required ApiEnum Field /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -37391,28 +44731,31 @@ public override void Validate() _ = this.Values; } - public PriceMinimumCompositePriceFilter() { } + public MeteredAllowanceCompositePriceFilter() { } - public PriceMinimumCompositePriceFilter( - PriceMinimumCompositePriceFilter priceMinimumCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceCompositePriceFilter( + MeteredAllowanceCompositePriceFilter meteredAllowanceCompositePriceFilter ) - : base(priceMinimumCompositePriceFilter) { } + : base(meteredAllowanceCompositePriceFilter) { } +#pragma warning restore CS8618 - public PriceMinimumCompositePriceFilter(IReadOnlyDictionary rawData) + public MeteredAllowanceCompositePriceFilter(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceMinimumCompositePriceFilter(FrozenDictionary rawData) + MeteredAllowanceCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimumCompositePriceFilter FromRawUnchecked( + /// + public static MeteredAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -37420,19 +44763,20 @@ IReadOnlyDictionary rawData } } -class PriceMinimumCompositePriceFilterFromRaw : IFromRawJson +class MeteredAllowanceCompositePriceFilterFromRaw + : IFromRawJson { /// - public PriceMinimumCompositePriceFilter FromRawUnchecked( + public MeteredAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceMinimumCompositePriceFilter.FromRawUnchecked(rawData); + ) => MeteredAllowanceCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterFieldConverter))] -public enum PriceMinimumCompositePriceFilterField +[JsonConverter(typeof(MeteredAllowanceCompositePriceFilterFieldConverter))] +public enum MeteredAllowanceCompositePriceFilterField { PriceID, ItemID, @@ -37441,10 +44785,10 @@ public enum PriceMinimumCompositePriceFilterField PricingUnitID, } -sealed class PriceMinimumCompositePriceFilterFieldConverter - : JsonConverter +sealed class MeteredAllowanceCompositePriceFilterFieldConverter + : JsonConverter { - public override PriceMinimumCompositePriceFilterField Read( + public override MeteredAllowanceCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37452,18 +44796,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" => MeteredAllowanceCompositePriceFilterField.PriceID, + "item_id" => MeteredAllowanceCompositePriceFilterField.ItemID, + "price_type" => MeteredAllowanceCompositePriceFilterField.PriceType, + "currency" => MeteredAllowanceCompositePriceFilterField.Currency, + "pricing_unit_id" => MeteredAllowanceCompositePriceFilterField.PricingUnitID, + _ => (MeteredAllowanceCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCompositePriceFilterField value, + MeteredAllowanceCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -37471,11 +44815,11 @@ 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", + MeteredAllowanceCompositePriceFilterField.PriceID => "price_id", + MeteredAllowanceCompositePriceFilterField.ItemID => "item_id", + MeteredAllowanceCompositePriceFilterField.PriceType => "price_type", + MeteredAllowanceCompositePriceFilterField.Currency => "currency", + MeteredAllowanceCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37488,17 +44832,510 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterOperatorConverter))] -public enum PriceMinimumCompositePriceFilterOperator +[JsonConverter(typeof(MeteredAllowanceCompositePriceFilterOperatorConverter))] +public enum MeteredAllowanceCompositePriceFilterOperator { Includes, Excludes, } -sealed class PriceMinimumCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MeteredAllowanceCompositePriceFilterOperatorConverter + : JsonConverter +{ + public override MeteredAllowanceCompositePriceFilterOperator Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "includes" => MeteredAllowanceCompositePriceFilterOperator.Includes, + "excludes" => MeteredAllowanceCompositePriceFilterOperator.Excludes, + _ => (MeteredAllowanceCompositePriceFilterOperator)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceCompositePriceFilterOperator value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MeteredAllowanceCompositePriceFilterOperator.Includes => "includes", + MeteredAllowanceCompositePriceFilterOperator.Excludes => "excludes", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MeteredAllowanceConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of MeteredAllowanceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of MeteredAllowanceConversionRateConfig" + ), + }; + } + + public static implicit operator MeteredAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MeteredAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of MeteredAllowanceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MeteredAllowanceConversionRateConfigConverter + : JsonConverter +{ + public override MeteredAllowanceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 MeteredAllowanceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// Configuration for metered_allowance pricing +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel +{ + /// + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); + } + } + + /// + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + /// + public string? ConsumptionDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); + } + } + + /// + public override void Validate() + { + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; + } + + public MeteredAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 + + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowanceConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MeteredAllowanceConfigFromRaw : IFromRawJson +{ + /// + public MeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MeteredAllowancePriceTypeConverter))] +public enum MeteredAllowancePriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class MeteredAllowancePriceTypeConverter : JsonConverter { - public override PriceMinimumCompositePriceFilterOperator Read( + public override MeteredAllowancePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37506,15 +45343,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => PriceMinimumCompositePriceFilterOperator.Includes, - "excludes" => PriceMinimumCompositePriceFilterOperator.Excludes, - _ => (PriceMinimumCompositePriceFilterOperator)(-1), + "usage_price" => MeteredAllowancePriceType.UsagePrice, + "fixed_price" => MeteredAllowancePriceType.FixedPrice, + "composite_price" => MeteredAllowancePriceType.CompositePrice, + _ => (MeteredAllowancePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCompositePriceFilterOperator value, + MeteredAllowancePriceType value, JsonSerializerOptions options ) { @@ -37522,8 +45360,9 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumCompositePriceFilterOperator.Includes => "includes", - PriceMinimumCompositePriceFilterOperator.Excludes => "excludes", + MeteredAllowancePriceType.UsagePrice => "usage_price", + MeteredAllowancePriceType.FixedPrice => "fixed_price", + MeteredAllowancePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37533,422 +45372,100 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase +/// +/// 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 MeteredAllowanceLicenseType : JsonModel { - 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); - /// } - /// - /// + /// The Orb-assigned unique identifier for the license type. /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ), - }; - } - - public static implicit operator PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator PriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(PriceMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PriceMinimumConversionRateConfigConverter - : JsonConverter -{ - public override PriceMinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public required string ID { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new PriceMinimumConversionRateConfig(element); - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); } + init { this._rawData.Set("id", value); } } - public override void Write( - Utf8JsonWriter writer, - PriceMinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -/// -/// Configuration for minimum pricing -/// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MinimumConfig : JsonModel -{ /// - /// The minimum amount to apply + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. /// - public required string MinimumAmount + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The name of the license type. /// - public bool? Prorated + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullClass("name"); } + init { this._rawData.Set("name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; } - public MinimumConfig() { } + public MeteredAllowanceLicenseType() { } - public MinimumConfig(MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceLicenseType(MeteredAllowanceLicenseType meteredAllowanceLicenseType) + : base(meteredAllowanceLicenseType) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceLicenseType(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + MeteredAllowanceLicenseType(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static MeteredAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class MeteredAllowanceLicenseTypeFromRaw : IFromRawJson { /// - public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - MinimumConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(PriceMinimumPriceTypeConverter))] -public enum PriceMinimumPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class PriceMinimumPriceTypeConverter : JsonConverter -{ - public override PriceMinimumPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => PriceMinimumPriceType.UsagePrice, - "fixed_price" => PriceMinimumPriceType.FixedPrice, - "composite_price" => PriceMinimumPriceType.CompositePrice, - _ => (PriceMinimumPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - PriceMinimumPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - PriceMinimumPriceType.UsagePrice => "usage_price", - PriceMinimumPriceType.FixedPrice => "fixed_price", - PriceMinimumPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + public MeteredAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceLicenseType.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] @@ -38111,6 +45628,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -38288,6 +45815,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() { @@ -38308,6 +45850,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -38330,6 +45873,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -38340,11 +45884,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 +46097,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 +46286,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 +46307,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 +46327,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 +46338,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38818,7 +46368,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 +46379,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38879,10 +46429,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 +46440,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +46488,10 @@ JsonSerializerOptions 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 +46508,10 @@ JsonSerializerOptions 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 +46589,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 +46682,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 { @@ -39278,6 +46936,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -39451,6 +47119,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() { @@ -39471,6 +47154,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -39488,6 +47172,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -39498,11 +47183,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 +47391,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 +47577,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 +47598,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 +47618,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 +47629,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -39968,7 +47659,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 +47670,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -40029,10 +47720,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 +47731,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +47778,10 @@ JsonSerializerOptions 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 +47798,10 @@ JsonSerializerOptions 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 +47852,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 +47939,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 { @@ -40407,6 +48203,16 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + public required string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -40569,6 +48375,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() { @@ -40590,6 +48411,7 @@ public override void Validate() this.EventOutputConfig.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -40611,6 +48433,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -40621,11 +48444,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 +48655,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 +48843,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 +48864,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 +48884,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 +48895,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41096,7 +48925,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 +48936,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41157,10 +48986,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 +48997,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +49045,10 @@ JsonSerializerOptions 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 +49065,10 @@ JsonSerializerOptions 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 +49150,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 +49238,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..9ab2ceb70 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; + } } /// @@ -159,6 +191,7 @@ public string Currency newFloatingPackageWithAllocationPrice: (x) => x.Currency, newFloatingUnitWithPercentPrice: (x) => x.Currency, newFloatingMatrixWithAllocationPrice: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, newFloatingTieredWithProrationPrice: (x) => x.Currency, newFloatingUnitWithProrationPrice: (x) => x.Currency, newFloatingGroupedAllocationPrice: (x) => x.Currency, @@ -173,7 +206,8 @@ public string Currency newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Currency, newFloatingCumulativeGroupedBulkPrice: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newFloatingMinimumCompositePrice: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -200,6 +234,7 @@ public string ItemID newFloatingPackageWithAllocationPrice: (x) => x.ItemID, newFloatingUnitWithPercentPrice: (x) => x.ItemID, newFloatingMatrixWithAllocationPrice: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, newFloatingTieredWithProrationPrice: (x) => x.ItemID, newFloatingUnitWithProrationPrice: (x) => x.ItemID, newFloatingGroupedAllocationPrice: (x) => x.ItemID, @@ -214,7 +249,8 @@ public string ItemID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ItemID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newFloatingMinimumCompositePrice: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -241,6 +277,7 @@ public string Name newFloatingPackageWithAllocationPrice: (x) => x.Name, newFloatingUnitWithPercentPrice: (x) => x.Name, newFloatingMatrixWithAllocationPrice: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, newFloatingTieredWithProrationPrice: (x) => x.Name, newFloatingUnitWithProrationPrice: (x) => x.Name, newFloatingGroupedAllocationPrice: (x) => x.Name, @@ -255,7 +292,8 @@ public string Name newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Name, newFloatingCumulativeGroupedBulkPrice: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newFloatingMinimumCompositePrice: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -282,6 +320,7 @@ public string? BillableMetricID newFloatingPackageWithAllocationPrice: (x) => x.BillableMetricID, newFloatingUnitWithPercentPrice: (x) => x.BillableMetricID, newFloatingMatrixWithAllocationPrice: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, newFloatingTieredWithProrationPrice: (x) => x.BillableMetricID, newFloatingUnitWithProrationPrice: (x) => x.BillableMetricID, newFloatingGroupedAllocationPrice: (x) => x.BillableMetricID, @@ -296,7 +335,8 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newFloatingMinimumCompositePrice: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -323,6 +363,7 @@ public bool? BilledInAdvance newFloatingPackageWithAllocationPrice: (x) => x.BilledInAdvance, newFloatingUnitWithPercentPrice: (x) => x.BilledInAdvance, newFloatingMatrixWithAllocationPrice: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, newFloatingTieredWithProrationPrice: (x) => x.BilledInAdvance, newFloatingUnitWithProrationPrice: (x) => x.BilledInAdvance, newFloatingGroupedAllocationPrice: (x) => x.BilledInAdvance, @@ -337,7 +378,8 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulkPrice: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newFloatingMinimumCompositePrice: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -364,6 +406,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingPackageWithAllocationPrice: (x) => x.BillingCycleConfiguration, newFloatingUnitWithPercentPrice: (x) => x.BillingCycleConfiguration, newFloatingMatrixWithAllocationPrice: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, newFloatingTieredWithProrationPrice: (x) => x.BillingCycleConfiguration, newFloatingUnitWithProrationPrice: (x) => x.BillingCycleConfiguration, newFloatingGroupedAllocationPrice: (x) => x.BillingCycleConfiguration, @@ -378,7 +421,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newFloatingMinimumCompositePrice: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -405,6 +449,7 @@ public double? ConversionRate newFloatingPackageWithAllocationPrice: (x) => x.ConversionRate, newFloatingUnitWithPercentPrice: (x) => x.ConversionRate, newFloatingMatrixWithAllocationPrice: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, newFloatingTieredWithProrationPrice: (x) => x.ConversionRate, newFloatingUnitWithProrationPrice: (x) => x.ConversionRate, newFloatingGroupedAllocationPrice: (x) => x.ConversionRate, @@ -419,7 +464,8 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulkPrice: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newFloatingMinimumCompositePrice: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -446,6 +492,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingPackageWithAllocationPrice: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithPercentPrice: (x) => x.DimensionalPriceConfiguration, newFloatingMatrixWithAllocationPrice: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, newFloatingTieredWithProrationPrice: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithProrationPrice: (x) => x.DimensionalPriceConfiguration, newFloatingGroupedAllocationPrice: (x) => x.DimensionalPriceConfiguration, @@ -462,7 +509,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumCompositePrice: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -489,6 +537,7 @@ public string? ExternalPriceID newFloatingPackageWithAllocationPrice: (x) => x.ExternalPriceID, newFloatingUnitWithPercentPrice: (x) => x.ExternalPriceID, newFloatingMatrixWithAllocationPrice: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, newFloatingTieredWithProrationPrice: (x) => x.ExternalPriceID, newFloatingUnitWithProrationPrice: (x) => x.ExternalPriceID, newFloatingGroupedAllocationPrice: (x) => x.ExternalPriceID, @@ -503,7 +552,8 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newFloatingMinimumCompositePrice: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -530,6 +580,7 @@ public double? FixedPriceQuantity newFloatingPackageWithAllocationPrice: (x) => x.FixedPriceQuantity, newFloatingUnitWithPercentPrice: (x) => x.FixedPriceQuantity, newFloatingMatrixWithAllocationPrice: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, newFloatingTieredWithProrationPrice: (x) => x.FixedPriceQuantity, newFloatingUnitWithProrationPrice: (x) => x.FixedPriceQuantity, newFloatingGroupedAllocationPrice: (x) => x.FixedPriceQuantity, @@ -544,7 +595,8 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulkPrice: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newFloatingMinimumCompositePrice: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -571,6 +623,7 @@ public string? InvoiceGroupingKey newFloatingPackageWithAllocationPrice: (x) => x.InvoiceGroupingKey, newFloatingUnitWithPercentPrice: (x) => x.InvoiceGroupingKey, newFloatingMatrixWithAllocationPrice: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, newFloatingTieredWithProrationPrice: (x) => x.InvoiceGroupingKey, newFloatingUnitWithProrationPrice: (x) => x.InvoiceGroupingKey, newFloatingGroupedAllocationPrice: (x) => x.InvoiceGroupingKey, @@ -585,7 +638,8 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulkPrice: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newFloatingMinimumCompositePrice: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -612,6 +666,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingPackageWithAllocationPrice: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithPercentPrice: (x) => x.InvoicingCycleConfiguration, newFloatingMatrixWithAllocationPrice: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, newFloatingTieredWithProrationPrice: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithProrationPrice: (x) => x.InvoicingCycleConfiguration, newFloatingGroupedAllocationPrice: (x) => x.InvoicingCycleConfiguration, @@ -627,7 +682,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumCompositePrice: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -635,6 +691,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (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 +752,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; @@ -719,6 +818,12 @@ public Body(NewFloatingMatrixWithAllocationPrice value, JsonElement? element = n this._element = element; } + public Body(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public Body(NewFloatingTieredWithProrationPrice value, JsonElement? element = null) { this.Value = value; @@ -755,10 +860,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 +902,19 @@ public Body(NewFloatingCumulativeGroupedBulkPrice value, JsonElement? element = this._element = element; } - public Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Body(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Body(DailyCreditAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Body(global::Orb.Models.Prices.Minimum value, JsonElement? element = null) + public Body(MeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -821,13 +926,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 +947,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 +968,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 +989,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 +1008,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 +1031,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 +1054,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 +1075,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 +1098,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 +1121,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 +1144,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 +1167,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 +1190,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 +1213,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 +1236,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. /// /// /// @@ -1152,11 +1255,34 @@ public bool TryPickNewFloatingMatrixWithAllocationPrice( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value + ) + { + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +1305,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 +1328,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 +1351,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 +1374,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 +1397,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 +1418,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 +1443,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 +1466,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 +1489,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 +1512,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 +1535,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 +1558,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 +1579,66 @@ 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; + value = this.Value as CumulativeGroupedAllocation; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; return value != null; } /// /// Returns true and sets 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.Prices.Minimum` + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Prices.Minimum? value) + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) { - value = this.Value as global::Orb.Models.Prices.Minimum; + value = this.Value as MeteredAllowance; return value != null; } @@ -1499,7 +1646,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 +1667,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 +1721,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1763,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, @@ -1627,24 +1774,26 @@ public void Switch( System::Action newFloatingPackageWithAllocationPrice, System::Action newFloatingUnitWithPercentPrice, System::Action newFloatingMatrixWithAllocationPrice, + System::Action matrixWithThresholdDiscounts, System::Action newFloatingTieredWithProrationPrice, System::Action newFloatingUnitWithProrationPrice, System::Action newFloatingGroupedAllocationPrice, 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 dailyCreditAllowance, + System::Action meteredAllowance, System::Action newFloatingMinimumCompositePrice, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1658,7 +1807,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: @@ -1691,6 +1840,9 @@ public void Switch( case NewFloatingMatrixWithAllocationPrice value: newFloatingMatrixWithAllocationPrice(value); break; + case MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case NewFloatingTieredWithProrationPrice value: newFloatingTieredWithProrationPrice(value); break; @@ -1709,7 +1861,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 +1882,22 @@ 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); + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(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 +1909,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 +1920,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1962,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, @@ -1822,6 +1979,7 @@ public T Match( > newFloatingPackageWithAllocationPrice, System::Func newFloatingUnitWithPercentPrice, System::Func newFloatingMatrixWithAllocationPrice, + System::Func matrixWithThresholdDiscounts, System::Func newFloatingTieredWithProrationPrice, System::Func newFloatingUnitWithProrationPrice, System::Func newFloatingGroupedAllocationPrice, @@ -1834,10 +1992,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 +2014,12 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice, T > newFloatingCumulativeGroupedBulkPrice, - System::Func< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func newFloatingMinimumCompositePrice, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -1874,7 +2027,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( @@ -1892,6 +2045,7 @@ public T Match( NewFloatingMatrixWithAllocationPrice value => newFloatingMatrixWithAllocationPrice( value ), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), NewFloatingTieredWithProrationPrice value => newFloatingTieredWithProrationPrice(value), NewFloatingUnitWithProrationPrice value => newFloatingUnitWithProrationPrice(value), NewFloatingGroupedAllocationPrice value => newFloatingGroupedAllocationPrice(value), @@ -1900,8 +2054,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 +2071,12 @@ 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), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(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 +2087,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); @@ -1958,6 +2110,8 @@ public static implicit operator Body(NewFloatingTieredPackageWithMinimumPrice va public static implicit operator Body(NewFloatingMatrixWithAllocationPrice value) => new(value); + public static implicit operator Body(MatrixWithThresholdDiscounts value) => new(value); + public static implicit operator Body(NewFloatingTieredWithProrationPrice value) => new(value); public static implicit operator Body(NewFloatingUnitWithProrationPrice value) => new(value); @@ -1972,9 +2126,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 +2142,17 @@ public static implicit operator Body(NewFloatingScalableMatrixWithTieredPricingP public static implicit operator Body(NewFloatingCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Body(CumulativeGroupedAllocation value) => new(value); + + public static implicit operator Body(DailyCreditAllowance value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.Minimum value) => new(value); + public static implicit operator Body(MeteredAllowance 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 @@ -2037,6 +2189,7 @@ public override void Validate() (newFloatingUnitWithPercentPrice) => newFloatingUnitWithPercentPrice.Validate(), (newFloatingMatrixWithAllocationPrice) => newFloatingMatrixWithAllocationPrice.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (newFloatingTieredWithProrationPrice) => newFloatingTieredWithProrationPrice.Validate(), (newFloatingUnitWithProrationPrice) => newFloatingUnitWithProrationPrice.Validate(), (newFloatingGroupedAllocationPrice) => newFloatingGroupedAllocationPrice.Validate(), @@ -2059,17 +2212,18 @@ public override void Validate() (newFloatingCumulativeGroupedBulkPrice) => newFloatingCumulativeGroupedBulkPrice.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +2231,52 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + 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, + MatrixWithThresholdDiscounts _ => 14, + NewFloatingTieredWithProrationPrice _ => 15, + NewFloatingUnitWithProrationPrice _ => 16, + NewFloatingGroupedAllocationPrice _ => 17, + NewFloatingBulkWithProrationPrice _ => 18, + NewFloatingGroupedWithProratedMinimumPrice _ => 19, + NewFloatingGroupedWithMeteredMinimumPrice _ => 20, + GroupedWithMinMaxThresholds _ => 21, + NewFloatingMatrixWithDisplayNamePrice _ => 22, + NewFloatingGroupedTieredPackagePrice _ => 23, + NewFloatingMaxGroupTieredPackagePrice _ => 24, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 25, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 26, + NewFloatingCumulativeGroupedBulkPrice _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + NewFloatingMinimumCompositePrice _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -2111,12 +2310,10 @@ JsonSerializerOptions 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 +2330,10 @@ JsonSerializerOptions 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 +2350,10 @@ JsonSerializerOptions 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 +2364,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 +2390,10 @@ JsonSerializerOptions 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 +2410,10 @@ JsonSerializerOptions 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 +2431,10 @@ JsonSerializerOptions 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 +2451,10 @@ JsonSerializerOptions 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 +2472,10 @@ JsonSerializerOptions 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 +2492,10 @@ JsonSerializerOptions 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 +2513,10 @@ JsonSerializerOptions 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 +2534,10 @@ JsonSerializerOptions 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 +2554,10 @@ JsonSerializerOptions 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 +2575,30 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -2426,12 +2616,10 @@ JsonSerializerOptions 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 +2637,10 @@ JsonSerializerOptions 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 +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 } @@ -2495,12 +2679,10 @@ JsonSerializerOptions 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 +2700,10 @@ JsonSerializerOptions 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 +2721,10 @@ JsonSerializerOptions 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 +2735,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 +2762,10 @@ JsonSerializerOptions 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 +2783,10 @@ JsonSerializerOptions 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 +2804,10 @@ JsonSerializerOptions 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 +2825,10 @@ JsonSerializerOptions 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 +2846,10 @@ JsonSerializerOptions 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 +2867,10 @@ JsonSerializerOptions 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 +2881,56 @@ 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 "daily_credit_allowance": { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = 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 +2947,10 @@ JsonSerializerOptions 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 +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 } @@ -2809,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 } @@ -2841,25 +3004,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 +3023,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 +3144,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 +3224,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3285,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3128,8 +3294,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 +3315,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 +3357,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 +3388,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 +3407,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 +3416,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 +3465,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 +3484,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 +3539,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 +3558,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 +3572,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 +3593,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 +3603,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 +3634,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 +3673,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 +3694,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 +3714,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 +3725,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3611,7 +3755,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 +3766,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3643,13 +3787,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 +3814,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 +3825,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 +3872,10 @@ JsonSerializerOptions 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 +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 } @@ -3754,14 +3904,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 +3920,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholds, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +public sealed record class MatrixWithThresholdDiscounts : 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); } @@ -3809,18 +3953,1847 @@ public required string Currency } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for matrix_with_threshold_discounts pricing + /// + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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 MatrixWithThresholdDiscountsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + } + + public MatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson +{ + /// + public MatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override MatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => MatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public MatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig + ) + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 + + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson +{ + /// + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public MatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 + + public MatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixValueFromRaw : IFromRawJson +{ + /// + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public ThresholdDiscountGroup() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 + + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ThresholdDiscountGroupFromRaw : IFromRawJson +{ + /// + public ThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public MatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } + + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 MatrixWithThresholdDiscountsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + MatrixWithThresholdDiscountsConversionRateConfig 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); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// Configuration for 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); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + 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(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 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); } + } + + /// + /// 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); } } /// @@ -3921,12 +5894,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 CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4003,6 +5976,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4028,13 +6014,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -4051,36 +6037,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public GroupedWithMinMaxThresholds() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4088,20 +6076,19 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -4111,10 +6098,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4122,23 +6109,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" => 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.GroupedWithMinMaxThresholdsCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -4146,14 +6129,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", + 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)) ), @@ -4164,99 +6145,102 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public GroupedWithMinMaxThresholdsConfig() { } + public CumulativeGroupedAllocationConfig() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,19 +6248,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4293,7 +6274,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4302,7 +6283,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4311,7 +6292,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -4320,7 +6301,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 +6322,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 +6342,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 +6353,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4393,7 +6374,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -4402,7 +6383,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 +6394,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4429,16 +6410,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4457,18 +6438,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 CumulativeGroupedAllocationConversionRateConfig" ); } 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(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4476,13 +6455,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4511,12 +6503,10 @@ JsonSerializerOptions 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 +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 } @@ -4547,16 +6535,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4564,58 +6550,50 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - global::Orb.Models.Prices.CumulativeGroupedAllocationFromRaw - >) -)] -public sealed record class CumulativeGroupedAllocation : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : 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 - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// An ISO 4217 currency string for which this price is billed in. /// - public required global::Orb.Models.Prices.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("currency", value); } } /// - /// An ISO 4217 currency string for which this price is billed in. + /// Configuration for daily_credit_allowance pricing /// - public required string Currency + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -4716,12 +6694,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 DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4798,6 +6776,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4823,13 +6814,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -4846,36 +6837,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public CumulativeGroupedAllocation() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Prices.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4883,20 +6876,19 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -4906,10 +6898,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.CumulativeGroupedAllocationCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4917,23 +6908,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" => DailyCreditAllowanceCadence.Annual, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "one_time" => DailyCreditAllowanceCadence.OneTime, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -4941,14 +6928,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", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4959,57 +6944,178 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class DailyCreditAllowanceConfig : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public DailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceConfigFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig, - global::Orb.Models.Prices.CumulativeGroupedAllocationConfigFromRaw + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class DailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -5024,34 +7130,35 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public DailyCreditAllowanceConfigMatrixValue() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue ) - : base(cumulativeGroupedAllocationConfig) { } + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,19 +7166,17 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5088,7 +7193,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5097,7 +7202,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5106,7 +7211,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5115,7 +7220,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 +7241,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 +7261,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 +7272,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5188,7 +7293,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -5197,7 +7302,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 +7313,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5224,16 +7329,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5252,18 +7357,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5271,13 +7374,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5306,12 +7422,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5328,12 +7442,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5342,16 +7454,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -5359,23 +7469,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Minimum, - global::Orb.Models.Prices.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -5407,18 +7514,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required global::Orb.Models.Prices.MinimumConfig MinimumConfig + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -5506,12 +7613,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5588,6 +7695,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5615,8 +7735,13 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -5631,34 +7756,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public Minimum() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public Minimum(global::Orb.Models.Prices.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Minimum FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5666,19 +7795,18 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Minimum.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -5688,9 +7816,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5698,19 +7826,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" => MeteredAllowanceCadence.Annual, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "one_time" => MeteredAllowanceCadence.OneTime, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -5718,12 +7846,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", + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5734,38 +7862,98 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.MinimumConfig, - global::Orb.Models.Prices.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -5774,61 +7962,61 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public MinimumConfig() { } + public MeteredAllowanceConfig() { } - public MinimumConfig(global::Orb.Models.Prices.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.MinimumConfig.FromRawUnchecked(rawData); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5845,7 +8033,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5854,7 +8042,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5863,7 +8051,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5872,7 +8060,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. /// /// /// @@ -5893,7 +8081,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. /// /// /// @@ -5913,7 +8101,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. /// /// @@ -5924,8 +8112,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5945,7 +8133,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -5954,7 +8142,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. /// /// @@ -5965,8 +8153,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5981,16 +8169,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6009,16 +8197,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 MeteredAllowanceConversionRateConfig" ); } 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6026,12 +8214,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6060,12 +8262,10 @@ JsonSerializerOptions 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 +8282,10 @@ JsonSerializerOptions 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 +8294,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6111,25 +8309,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 +8380,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 +8449,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 +8531,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8587,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6393,8 +8596,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 +8617,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 +8645,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 +8655,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 +8675,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 +8693,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 +8717,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 +8736,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 +8750,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 +8802,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 +8823,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 +8843,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 +8854,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6686,7 +8884,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 +8895,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6718,11 +8916,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 +8945,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 +8956,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 +9003,10 @@ JsonSerializerOptions 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 +9023,10 @@ JsonSerializerOptions 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 +9035,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 +9050,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 +9082,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 +9190,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 +9272,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9333,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7131,8 +9342,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 +9363,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 +9391,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 +9401,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 +9421,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 +9439,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 +9494,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 +9513,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 +9529,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 +9581,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 +9602,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 +9622,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 +9633,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7456,7 +9663,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 +9674,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7488,11 +9695,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 +9724,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 +9735,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 +9783,10 @@ JsonSerializerOptions 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 +9803,10 @@ JsonSerializerOptions 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 +9815,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..a6afcbc54 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; @@ -363,6 +429,7 @@ public string Currency newFloatingPackageWithAllocation: (x) => x.Currency, newFloatingUnitWithPercent: (x) => x.Currency, newFloatingMatrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, newFloatingTieredWithProration: (x) => x.Currency, newFloatingUnitWithProration: (x) => x.Currency, newFloatingGroupedAllocation: (x) => x.Currency, @@ -377,7 +444,8 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -404,6 +472,7 @@ public string ItemID newFloatingPackageWithAllocation: (x) => x.ItemID, newFloatingUnitWithPercent: (x) => x.ItemID, newFloatingMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, newFloatingTieredWithProration: (x) => x.ItemID, newFloatingUnitWithProration: (x) => x.ItemID, newFloatingGroupedAllocation: (x) => x.ItemID, @@ -418,7 +487,8 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -445,6 +515,7 @@ public string Name newFloatingPackageWithAllocation: (x) => x.Name, newFloatingUnitWithPercent: (x) => x.Name, newFloatingMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, newFloatingTieredWithProration: (x) => x.Name, newFloatingUnitWithProration: (x) => x.Name, newFloatingGroupedAllocation: (x) => x.Name, @@ -459,7 +530,8 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -486,6 +558,7 @@ public string? BillableMetricID newFloatingPackageWithAllocation: (x) => x.BillableMetricID, newFloatingUnitWithPercent: (x) => x.BillableMetricID, newFloatingMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, newFloatingTieredWithProration: (x) => x.BillableMetricID, newFloatingUnitWithProration: (x) => x.BillableMetricID, newFloatingGroupedAllocation: (x) => x.BillableMetricID, @@ -500,7 +573,8 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -527,6 +601,7 @@ public bool? BilledInAdvance newFloatingPackageWithAllocation: (x) => x.BilledInAdvance, newFloatingUnitWithPercent: (x) => x.BilledInAdvance, newFloatingMatrixWithAllocation: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, newFloatingTieredWithProration: (x) => x.BilledInAdvance, newFloatingUnitWithProration: (x) => x.BilledInAdvance, newFloatingGroupedAllocation: (x) => x.BilledInAdvance, @@ -541,7 +616,8 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -568,6 +644,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.BillingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.BillingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, newFloatingTieredWithProration: (x) => x.BillingCycleConfiguration, newFloatingUnitWithProration: (x) => x.BillingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.BillingCycleConfiguration, @@ -582,7 +659,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -609,6 +687,7 @@ public double? ConversionRate newFloatingPackageWithAllocation: (x) => x.ConversionRate, newFloatingUnitWithPercent: (x) => x.ConversionRate, newFloatingMatrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, newFloatingTieredWithProration: (x) => x.ConversionRate, newFloatingUnitWithProration: (x) => x.ConversionRate, newFloatingGroupedAllocation: (x) => x.ConversionRate, @@ -623,7 +702,8 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -650,6 +730,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithPercent: (x) => x.DimensionalPriceConfiguration, newFloatingMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, newFloatingTieredWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingGroupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -664,7 +745,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -691,6 +773,7 @@ public string? ExternalPriceID newFloatingPackageWithAllocation: (x) => x.ExternalPriceID, newFloatingUnitWithPercent: (x) => x.ExternalPriceID, newFloatingMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, newFloatingTieredWithProration: (x) => x.ExternalPriceID, newFloatingUnitWithProration: (x) => x.ExternalPriceID, newFloatingGroupedAllocation: (x) => x.ExternalPriceID, @@ -705,7 +788,8 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -732,6 +816,7 @@ public double? FixedPriceQuantity newFloatingPackageWithAllocation: (x) => x.FixedPriceQuantity, newFloatingUnitWithPercent: (x) => x.FixedPriceQuantity, newFloatingMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, newFloatingTieredWithProration: (x) => x.FixedPriceQuantity, newFloatingUnitWithProration: (x) => x.FixedPriceQuantity, newFloatingGroupedAllocation: (x) => x.FixedPriceQuantity, @@ -746,7 +831,8 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -773,6 +859,7 @@ public string? InvoiceGroupingKey newFloatingPackageWithAllocation: (x) => x.InvoiceGroupingKey, newFloatingUnitWithPercent: (x) => x.InvoiceGroupingKey, newFloatingMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, newFloatingTieredWithProration: (x) => x.InvoiceGroupingKey, newFloatingUnitWithProration: (x) => x.InvoiceGroupingKey, newFloatingGroupedAllocation: (x) => x.InvoiceGroupingKey, @@ -787,7 +874,8 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -814,6 +902,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.InvoicingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, newFloatingTieredWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -828,7 +917,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -836,6 +926,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (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; @@ -920,6 +1053,12 @@ public Price(NewFloatingMatrixWithAllocationPrice value, JsonElement? element = this._element = element; } + public Price(PriceMatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public Price(NewFloatingTieredWithProrationPrice value, JsonElement? element = null) { this.Value = value; @@ -1004,7 +1143,13 @@ public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public Price(global::Orb.Models.Prices.PriceMinimum value, JsonElement? element = null) + public Price(PriceDailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(PriceMeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1037,7 +1182,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 +1203,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 +1224,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 +1245,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 +1266,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 +1287,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 +1308,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 +1331,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 +1354,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 +1377,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 +1400,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 +1423,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 +1446,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 +1469,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. /// /// /// @@ -1343,11 +1488,34 @@ public bool TryPickNewFloatingMatrixWithAllocation( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `PriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out PriceMatrixWithThresholdDiscounts? value + ) + { + value = this.Value as PriceMatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +1538,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 +1561,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 +1584,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 +1607,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 +1630,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 +1653,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 +1676,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 +1699,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 +1722,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 +1745,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 +1768,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 +1791,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 +1814,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. /// /// /// @@ -1667,24 +1835,45 @@ public bool TryPickCumulativeGroupedAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// 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` + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `PriceDailyCreditAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Prices.PriceMinimum? value + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out PriceDailyCreditAllowance? value ) { - value = this.Value as global::Orb.Models.Prices.PriceMinimum; + value = this.Value as PriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `PriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance([NotNullWhen(true)] out PriceMeteredAllowance? value) + { + value = this.Value as PriceMeteredAllowance; return value != null; } @@ -1692,7 +1881,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. /// /// /// @@ -1715,7 +1904,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 +1925,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 +1945,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 +1956,40 @@ 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) => {...}, + /// (PriceMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceDailyCreditAllowance value) => {...}, + /// (PriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput value) => {...} /// ); /// /// @@ -1818,6 +2009,7 @@ public void Switch( System::Action newFloatingPackageWithAllocation, System::Action newFloatingUnitWithPercent, System::Action newFloatingMatrixWithAllocation, + System::Action matrixWithThresholdDiscounts, System::Action newFloatingTieredWithProration, System::Action newFloatingUnitWithProration, System::Action newFloatingGroupedAllocation, @@ -1832,7 +2024,8 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -1882,6 +2075,9 @@ public void Switch( case NewFloatingMatrixWithAllocationPrice value: newFloatingMatrixWithAllocation(value); break; + case PriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case NewFloatingTieredWithProrationPrice value: newFloatingTieredWithProration(value); break; @@ -1924,8 +2120,11 @@ public void Switch( case PriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.PriceMinimum value: - minimum(value); + case PriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case PriceMeteredAllowance value: + meteredAllowance(value); break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); @@ -1945,7 +2144,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 +2155,40 @@ 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) => {...}, + /// (PriceMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceDailyCreditAllowance value) => {...}, + /// (PriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput value) => {...} /// ); /// /// @@ -2010,6 +2211,7 @@ public T Match( System::Func newFloatingPackageWithAllocation, System::Func newFloatingUnitWithPercent, System::Func newFloatingMatrixWithAllocation, + System::Func matrixWithThresholdDiscounts, System::Func newFloatingTieredWithProration, System::Func newFloatingUnitWithProration, System::Func newFloatingGroupedAllocation, @@ -2036,7 +2238,8 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2060,6 +2263,7 @@ public T Match( NewFloatingPackageWithAllocationPrice value => newFloatingPackageWithAllocation(value), NewFloatingUnitWithPercentPrice value => newFloatingUnitWithPercent(value), NewFloatingMatrixWithAllocationPrice value => newFloatingMatrixWithAllocation(value), + PriceMatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), NewFloatingTieredWithProrationPrice value => newFloatingTieredWithProration(value), NewFloatingUnitWithProrationPrice value => newFloatingUnitWithProration(value), NewFloatingGroupedAllocationPrice value => newFloatingGroupedAllocation(value), @@ -2079,7 +2283,8 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.PriceMinimum value => minimum(value), + PriceDailyCreditAllowance value => dailyCreditAllowance(value), + PriceMeteredAllowance value => meteredAllowance(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PricePercent value => percent(value), PriceEventOutput value => eventOutput(value), @@ -2087,126 +2292,82 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingUnitPrice value) => - new(value); + public static implicit operator Price(NewFloatingUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingTieredPrice value) => - new(value); + public static implicit operator Price(NewFloatingTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingBulkPrice value) => - new(value); + public static implicit operator Price(NewFloatingBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceBulkWithFilters value) => - new(value); + public static implicit operator Price(PriceBulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingMatrixPrice value) => - new(value); + public static implicit operator Price(NewFloatingMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewFloatingThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithProrationPrice value - ) => new(value); + public static implicit operator Price(PriceMatrixWithThresholdDiscounts 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(PriceDailyCreditAllowance value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PricePercent value) => - new(value); + public static implicit operator Price(PriceMeteredAllowance value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceEventOutput value) => - new(value); + public static implicit operator Price(NewFloatingMinimumCompositePrice 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 @@ -2239,6 +2400,7 @@ public override void Validate() (newFloatingPackageWithAllocation) => newFloatingPackageWithAllocation.Validate(), (newFloatingUnitWithPercent) => newFloatingUnitWithPercent.Validate(), (newFloatingMatrixWithAllocation) => newFloatingMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (newFloatingTieredWithProration) => newFloatingTieredWithProration.Validate(), (newFloatingUnitWithProration) => newFloatingUnitWithProration.Validate(), (newFloatingGroupedAllocation) => newFloatingGroupedAllocation.Validate(), @@ -2257,17 +2419,18 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +2438,57 @@ public override int GetHashCode() } 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, + PriceMatrixWithThresholdDiscounts _ => 14, + NewFloatingTieredWithProrationPrice _ => 15, + NewFloatingUnitWithProrationPrice _ => 16, + NewFloatingGroupedAllocationPrice _ => 17, + NewFloatingBulkWithProrationPrice _ => 18, + NewFloatingGroupedWithProratedMinimumPrice _ => 19, + NewFloatingGroupedWithMeteredMinimumPrice _ => 20, + PriceGroupedWithMinMaxThresholds _ => 21, + NewFloatingMatrixWithDisplayNamePrice _ => 22, + NewFloatingGroupedTieredPackagePrice _ => 23, + NewFloatingMaxGroupTieredPackagePrice _ => 24, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 25, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 26, + NewFloatingCumulativeGroupedBulkPrice _ => 27, + PriceCumulativeGroupedAllocation _ => 28, + PriceDailyCreditAllowance _ => 29, + PriceMeteredAllowance _ => 30, + NewFloatingMinimumCompositePrice _ => 31, + PricePercent _ => 32, + PriceEventOutput _ => 33, + _ => -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 +2517,10 @@ JsonSerializerOptions 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 +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 } @@ -2353,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 } @@ -2375,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 } @@ -2397,12 +2597,10 @@ JsonSerializerOptions 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 +2617,10 @@ JsonSerializerOptions 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 +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 } @@ -2464,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 } @@ -2487,12 +2679,10 @@ JsonSerializerOptions 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 +2699,10 @@ JsonSerializerOptions 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 +2720,10 @@ JsonSerializerOptions 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 +2741,10 @@ JsonSerializerOptions 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 +2761,10 @@ JsonSerializerOptions 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 +2782,31 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -2623,12 +2824,10 @@ JsonSerializerOptions 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 +2845,10 @@ JsonSerializerOptions 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 +2866,10 @@ JsonSerializerOptions 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 +2887,10 @@ JsonSerializerOptions 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 +2908,10 @@ JsonSerializerOptions 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 +2929,10 @@ JsonSerializerOptions 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 +2949,10 @@ JsonSerializerOptions 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 +2970,10 @@ JsonSerializerOptions 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 +2991,10 @@ JsonSerializerOptions 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 +3012,10 @@ JsonSerializerOptions 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 +3033,10 @@ JsonSerializerOptions 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 +3054,10 @@ JsonSerializerOptions 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 +3075,10 @@ JsonSerializerOptions 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 +3095,50 @@ JsonSerializerOptions 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 "daily_credit_allowance": { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = 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 +3155,10 @@ JsonSerializerOptions 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 +3172,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 +3192,10 @@ JsonSerializerOptions 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 +3204,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 +3441,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3502,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3317,8 +3511,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 +3617,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 +3704,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 +3791,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 +3943,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 +3964,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 +3984,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 +3995,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3819,7 +4025,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 +4036,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3880,10 +4086,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 +4097,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +4145,10 @@ JsonSerializerOptions 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 +4165,10 @@ JsonSerializerOptions 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,22 +4194,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceGroupedWithMinMaxThresholds, - PriceGroupedWithMinMaxThresholdsFromRaw + PriceMatrixWithThresholdDiscounts, + PriceMatrixWithThresholdDiscountsFromRaw >) )] -public sealed record class PriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class PriceMatrixWithThresholdDiscounts : 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); } @@ -4014,31 +4229,31 @@ public required string Currency } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for matrix_with_threshold_discounts pricing /// - public required string ItemID + public required PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// @@ -4126,12 +4341,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public PriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4208,6 +4423,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4234,12 +4462,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.Currency; - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { @@ -4256,36 +4484,1934 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceGroupedWithMinMaxThresholds() + public PriceMatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public PriceGroupedWithMinMaxThresholds( +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMatrixWithThresholdDiscounts( + PriceMatrixWithThresholdDiscounts priceMatrixWithThresholdDiscounts + ) + : base(priceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 + + public PriceMatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceMatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceMatrixWithThresholdDiscountsFromRaw : IFromRawJson +{ + /// + public PriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceMatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceMatrixWithThresholdDiscountsCadenceConverter))] +public enum PriceMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override PriceMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => PriceMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => PriceMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => PriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => PriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => PriceMatrixWithThresholdDiscountsCadence.Custom, + _ => (PriceMatrixWithThresholdDiscountsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceMatrixWithThresholdDiscountsCadence.Annual => "annual", + PriceMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + PriceMatrixWithThresholdDiscountsCadence.Monthly => "monthly", + PriceMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + PriceMatrixWithThresholdDiscountsCadence.OneTime => "one_time", + PriceMatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base(priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base(priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue) { } +#pragma warning restore CS8618 + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + priceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 + + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(PriceMatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class PriceMatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceMatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceMatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override PriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceMatrixWithThresholdDiscountsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceMatrixWithThresholdDiscountsConversionRateConfig 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); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// Configuration for 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); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + public PriceGroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceGroupedWithMinMaxThresholds( PriceGroupedWithMinMaxThresholds priceGroupedWithMinMaxThresholds ) - : base(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); } + } + + /// + /// 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); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.Currency; + _ = 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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + 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 PriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + PriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static PriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4293,19 +6419,19 @@ IReadOnlyDictionary rawData } } -class PriceGroupedWithMinMaxThresholdsFromRaw : IFromRawJson +class PriceCumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public PriceGroupedWithMinMaxThresholds FromRawUnchecked( + public PriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => PriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum PriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(PriceCumulativeGroupedAllocationCadenceConverter))] +public enum PriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -4315,10 +6441,10 @@ public enum PriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class PriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override PriceGroupedWithMinMaxThresholdsCadence Read( + public override PriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4326,19 +6452,19 @@ 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), + "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, - PriceGroupedWithMinMaxThresholdsCadence value, + PriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -4346,12 +6472,12 @@ JsonSerializerOptions options writer, value switch { - PriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - PriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - PriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - PriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - PriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - PriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", + 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)) ), @@ -4362,86 +6488,89 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -4450,7 +6579,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -4458,8 +6587,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4467,18 +6596,18 @@ IReadOnlyDictionary rawData } } -class PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class PriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4495,7 +6624,7 @@ public JsonElement Json } } - public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4504,7 +6633,7 @@ public PriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public PriceGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4513,7 +6642,7 @@ public PriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public PriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -4522,7 +6651,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 +6672,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 +6692,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 +6703,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4595,7 +6724,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -4604,7 +6733,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 +6744,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4631,16 +6760,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4659,16 +6788,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" ); } 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(PriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4676,13 +6805,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 PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override PriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4711,12 +6853,10 @@ JsonSerializerOptions 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 +6873,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4747,14 +6885,14 @@ JsonSerializerOptions options } default: { - return new PriceGroupedWithMinMaxThresholdsConversionRateConfig(element); + return new PriceCumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceGroupedWithMinMaxThresholdsConversionRateConfig value, + PriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4763,54 +6901,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - PriceCumulativeGroupedAllocation, - PriceCumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class PriceCumulativeGroupedAllocation : JsonModel +public sealed record class PriceDailyCreditAllowance : 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 cumulative_grouped_allocation pricing + /// An ISO 4217 currency string for which this price is billed in. /// - public required PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("currency", value); } } /// - /// An ISO 4217 currency string for which this price is billed in. + /// Configuration for daily_credit_allowance pricing /// - public required string Currency + public required PriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -4911,12 +7046,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public PriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4993,6 +7128,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5018,13 +7166,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -5041,36 +7189,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceCumulativeGroupedAllocation() + public PriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public PriceCumulativeGroupedAllocation( - PriceCumulativeGroupedAllocation priceCumulativeGroupedAllocation - ) - : base(priceCumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceDailyCreditAllowance(PriceDailyCreditAllowance priceDailyCreditAllowance) + : base(priceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public PriceDailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceCumulativeGroupedAllocation(FrozenDictionary rawData) + PriceDailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static PriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5078,19 +7228,19 @@ IReadOnlyDictionary rawData } } -class PriceCumulativeGroupedAllocationFromRaw : IFromRawJson +class PriceDailyCreditAllowanceFromRaw : IFromRawJson { /// - public PriceCumulativeGroupedAllocation FromRawUnchecked( + public PriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => PriceDailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceCumulativeGroupedAllocationCadenceConverter))] -public enum PriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(PriceDailyCreditAllowanceCadenceConverter))] +public enum PriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -5100,10 +7250,10 @@ public enum PriceCumulativeGroupedAllocationCadence Custom, } -sealed class PriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override PriceCumulativeGroupedAllocationCadence Read( + public override PriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5111,94 +7261,224 @@ 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), + "annual" => PriceDailyCreditAllowanceCadence.Annual, + "semi_annual" => PriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => PriceDailyCreditAllowanceCadence.Monthly, + "quarterly" => PriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => PriceDailyCreditAllowanceCadence.OneTime, + "custom" => PriceDailyCreditAllowanceCadence.Custom, + _ => (PriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceCumulativeGroupedAllocationCadence value, + PriceDailyCreditAllowanceCadence 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 - ); + JsonSerializer.Serialize( + writer, + value switch + { + PriceDailyCreditAllowanceCadence.Annual => "annual", + PriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + PriceDailyCreditAllowanceCadence.Monthly => "monthly", + PriceDailyCreditAllowanceCadence.Quarterly => "quarterly", + PriceDailyCreditAllowanceCadence.OneTime => "one_time", + PriceDailyCreditAllowanceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceDailyCreditAllowanceDailyCreditAllowanceConfig, + PriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class PriceDailyCreditAllowanceDailyCreditAllowanceConfig : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public PriceDailyCreditAllowanceDailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceDailyCreditAllowanceDailyCreditAllowanceConfig( + PriceDailyCreditAllowanceDailyCreditAllowanceConfig priceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base(priceDailyCreditAllowanceDailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public PriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } +class PriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public PriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + /// -/// Configuration for cumulative_grouped_allocation pricing +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -5213,20 +7493,21 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) - : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(priceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -5235,7 +7516,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -5243,8 +7524,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5252,18 +7533,17 @@ IReadOnlyDictionary rawData } } -class PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => - PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class PriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceDailyCreditAllowanceConversionRateConfigConverter))] +public record class PriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5280,7 +7560,7 @@ public JsonElement Json } } - public PriceCumulativeGroupedAllocationConversionRateConfig( + public PriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5289,7 +7569,7 @@ public PriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public PriceCumulativeGroupedAllocationConversionRateConfig( + public PriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5298,7 +7578,7 @@ public PriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public PriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5307,7 +7587,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 +7608,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 +7628,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 +7639,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5380,7 +7660,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -5389,7 +7669,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 +7680,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5416,16 +7696,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5444,16 +7724,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" ); } 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(PriceDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5461,13 +7741,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 PriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class PriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override PriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5496,12 +7789,10 @@ JsonSerializerOptions 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 +7809,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5532,14 +7821,14 @@ JsonSerializerOptions options } default: { - return new PriceCumulativeGroupedAllocationConversionRateConfig(element); + return new PriceDailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceCumulativeGroupedAllocationConversionRateConfig value, + PriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -5547,25 +7836,20 @@ 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 PriceMeteredAllowance : 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,16 +7881,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required PriceMinimumMinimumConfig MinimumConfig + public required PriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -5694,12 +7980,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 PriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5776,6 +8062,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5803,8 +8102,13 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -5819,34 +8123,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceMinimum() + public PriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public PriceMinimum(global::Orb.Models.Prices.PriceMinimum priceMinimum) - : base(priceMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMeteredAllowance(PriceMeteredAllowance priceMeteredAllowance) + : base(priceMeteredAllowance) { } +#pragma warning restore CS8618 - public PriceMinimum(IReadOnlyDictionary rawData) + public PriceMeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) + PriceMeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( + /// + public static PriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5854,19 +8162,19 @@ IReadOnlyDictionary rawData } } -class PriceMinimumFromRaw : IFromRawJson +class PriceMeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( + public PriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PriceMinimum.FromRawUnchecked(rawData); + ) => PriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(PriceMeteredAllowanceCadenceConverter))] +public enum PriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -5876,10 +8184,9 @@ public enum PriceMinimumCadence Custom, } -sealed class PriceMinimumCadenceConverter - : JsonConverter +sealed class PriceMeteredAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.PriceMinimumCadence Read( + public override PriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5887,19 +8194,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.PriceMinimumCadence.Annual, - "semi_annual" => global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.PriceMinimumCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.PriceMinimumCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.PriceMinimumCadence.OneTime, - "custom" => global::Orb.Models.Prices.PriceMinimumCadence.Custom, - _ => (global::Orb.Models.Prices.PriceMinimumCadence)(-1), + "annual" => PriceMeteredAllowanceCadence.Annual, + "semi_annual" => PriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => PriceMeteredAllowanceCadence.Monthly, + "quarterly" => PriceMeteredAllowanceCadence.Quarterly, + "one_time" => PriceMeteredAllowanceCadence.OneTime, + "custom" => PriceMeteredAllowanceCadence.Custom, + _ => (PriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumCadence value, + PriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -5907,12 +8214,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.PriceMinimumCadence.Annual => "annual", - global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.PriceMinimumCadence.Monthly => "monthly", - global::Orb.Models.Prices.PriceMinimumCadence.Quarterly => "quarterly", - global::Orb.Models.Prices.PriceMinimumCadence.OneTime => "one_time", - global::Orb.Models.Prices.PriceMinimumCadence.Custom => "custom", + PriceMeteredAllowanceCadence.Annual => "annual", + PriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", + PriceMeteredAllowanceCadence.Monthly => "monthly", + PriceMeteredAllowanceCadence.Quarterly => "quarterly", + PriceMeteredAllowanceCadence.OneTime => "one_time", + PriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5923,35 +8230,103 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + PriceMeteredAllowanceMeteredAllowanceConfig, + PriceMeteredAllowanceMeteredAllowanceConfigFromRaw + >) )] -public sealed record class PriceMinimumMinimumConfig : JsonModel +public sealed record class PriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -5960,61 +8335,66 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public PriceMinimumMinimumConfig() { } + public PriceMeteredAllowanceMeteredAllowanceConfig() { } - public PriceMinimumMinimumConfig(PriceMinimumMinimumConfig priceMinimumMinimumConfig) - : base(priceMinimumMinimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceMeteredAllowanceMeteredAllowanceConfig( + PriceMeteredAllowanceMeteredAllowanceConfig priceMeteredAllowanceMeteredAllowanceConfig + ) + : base(priceMeteredAllowanceMeteredAllowanceConfig) { } +#pragma warning restore CS8618 - public PriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public PriceMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceMinimumMinimumConfig(FrozenDictionary rawData) + PriceMeteredAllowanceMeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimumMinimumConfig FromRawUnchecked( + /// + public static PriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class PriceMinimumMinimumConfigFromRaw : IFromRawJson +class PriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public PriceMinimumMinimumConfig FromRawUnchecked( + public PriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => PriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceMeteredAllowanceConversionRateConfigConverter))] +public record class PriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6031,7 +8411,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public PriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6040,7 +8420,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public PriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6049,7 +8429,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public PriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6058,7 +8438,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. /// /// /// @@ -6079,7 +8459,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. /// /// /// @@ -6099,7 +8479,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. /// /// @@ -6110,8 +8490,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6131,7 +8511,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" + "Data did not match any variant of PriceMeteredAllowanceConversionRateConfig" ); } } @@ -6140,7 +8520,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. /// /// @@ -6151,8 +8531,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6167,16 +8547,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 PriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( + public static implicit operator PriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( + public static implicit operator PriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6195,16 +8575,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 PriceMeteredAllowanceConversionRateConfig" ); } 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 virtual bool Equals(PriceMeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6212,13 +8592,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 PriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Prices.PriceMinimumConversionRateConfig? Read( + public override PriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6247,12 +8640,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6269,12 +8660,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6283,14 +8672,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.PriceMinimumConversionRateConfig(element); + return new PriceMeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumConversionRateConfig value, + PriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6520,6 +8909,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6563,6 +8965,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6571,8 +8974,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 +9097,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 +9185,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 +9206,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 +9226,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 +9237,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6858,7 +9267,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 +9278,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6919,10 +9328,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 +9339,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9387,10 @@ JsonSerializerOptions 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 +9407,10 @@ JsonSerializerOptions 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 +9660,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9721,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7298,8 +9730,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 +9889,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 +9979,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 +10000,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 +10020,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 +10031,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7623,7 +10061,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 +10072,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7684,10 +10122,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 +10133,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10181,10 @@ JsonSerializerOptions 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 +10201,10 @@ JsonSerializerOptions 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..b041f414c 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 @@ -516,6 +585,7 @@ public string Currency newFloatingPackageWithAllocation: (x) => x.Currency, newFloatingUnitWithPercent: (x) => x.Currency, newFloatingMatrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, newFloatingTieredWithProration: (x) => x.Currency, newFloatingUnitWithProration: (x) => x.Currency, newFloatingGroupedAllocation: (x) => x.Currency, @@ -530,7 +600,8 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -557,6 +628,7 @@ public string ItemID newFloatingPackageWithAllocation: (x) => x.ItemID, newFloatingUnitWithPercent: (x) => x.ItemID, newFloatingMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, newFloatingTieredWithProration: (x) => x.ItemID, newFloatingUnitWithProration: (x) => x.ItemID, newFloatingGroupedAllocation: (x) => x.ItemID, @@ -571,7 +643,8 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -598,6 +671,7 @@ public string Name newFloatingPackageWithAllocation: (x) => x.Name, newFloatingUnitWithPercent: (x) => x.Name, newFloatingMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, newFloatingTieredWithProration: (x) => x.Name, newFloatingUnitWithProration: (x) => x.Name, newFloatingGroupedAllocation: (x) => x.Name, @@ -612,7 +686,8 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -639,6 +714,7 @@ public string? BillableMetricID newFloatingPackageWithAllocation: (x) => x.BillableMetricID, newFloatingUnitWithPercent: (x) => x.BillableMetricID, newFloatingMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, newFloatingTieredWithProration: (x) => x.BillableMetricID, newFloatingUnitWithProration: (x) => x.BillableMetricID, newFloatingGroupedAllocation: (x) => x.BillableMetricID, @@ -653,7 +729,8 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -680,6 +757,7 @@ public bool? BilledInAdvance newFloatingPackageWithAllocation: (x) => x.BilledInAdvance, newFloatingUnitWithPercent: (x) => x.BilledInAdvance, newFloatingMatrixWithAllocation: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, newFloatingTieredWithProration: (x) => x.BilledInAdvance, newFloatingUnitWithProration: (x) => x.BilledInAdvance, newFloatingGroupedAllocation: (x) => x.BilledInAdvance, @@ -694,7 +772,8 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -721,6 +800,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.BillingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.BillingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, newFloatingTieredWithProration: (x) => x.BillingCycleConfiguration, newFloatingUnitWithProration: (x) => x.BillingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.BillingCycleConfiguration, @@ -735,7 +815,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -762,6 +843,7 @@ public double? ConversionRate newFloatingPackageWithAllocation: (x) => x.ConversionRate, newFloatingUnitWithPercent: (x) => x.ConversionRate, newFloatingMatrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, newFloatingTieredWithProration: (x) => x.ConversionRate, newFloatingUnitWithProration: (x) => x.ConversionRate, newFloatingGroupedAllocation: (x) => x.ConversionRate, @@ -776,7 +858,8 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -803,6 +886,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithPercent: (x) => x.DimensionalPriceConfiguration, newFloatingMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, newFloatingTieredWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingGroupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -817,7 +901,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -844,6 +929,7 @@ public string? ExternalPriceID newFloatingPackageWithAllocation: (x) => x.ExternalPriceID, newFloatingUnitWithPercent: (x) => x.ExternalPriceID, newFloatingMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, newFloatingTieredWithProration: (x) => x.ExternalPriceID, newFloatingUnitWithProration: (x) => x.ExternalPriceID, newFloatingGroupedAllocation: (x) => x.ExternalPriceID, @@ -858,7 +944,8 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -885,6 +972,7 @@ public double? FixedPriceQuantity newFloatingPackageWithAllocation: (x) => x.FixedPriceQuantity, newFloatingUnitWithPercent: (x) => x.FixedPriceQuantity, newFloatingMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, newFloatingTieredWithProration: (x) => x.FixedPriceQuantity, newFloatingUnitWithProration: (x) => x.FixedPriceQuantity, newFloatingGroupedAllocation: (x) => x.FixedPriceQuantity, @@ -899,7 +987,8 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -926,6 +1015,7 @@ public string? InvoiceGroupingKey newFloatingPackageWithAllocation: (x) => x.InvoiceGroupingKey, newFloatingUnitWithPercent: (x) => x.InvoiceGroupingKey, newFloatingMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, newFloatingTieredWithProration: (x) => x.InvoiceGroupingKey, newFloatingUnitWithProration: (x) => x.InvoiceGroupingKey, newFloatingGroupedAllocation: (x) => x.InvoiceGroupingKey, @@ -940,7 +1030,8 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -967,6 +1058,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.InvoicingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, newFloatingTieredWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -981,7 +1073,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -989,6 +1082,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newFloatingMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingUnitPrice value, JsonElement? element = null @@ -1115,6 +1251,15 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( this._element = element; } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingTieredWithProrationPrice value, JsonElement? element = null @@ -1242,7 +1387,16 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( } public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value, JsonElement? element = null ) { @@ -1286,7 +1440,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 +1461,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 +1482,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 +1503,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 +1527,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 +1548,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 +1569,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 +1592,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 +1615,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 +1638,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 +1661,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 +1684,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 +1707,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 +1730,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. /// /// /// @@ -1595,11 +1749,37 @@ public bool TryPickNewFloatingMatrixWithAllocation( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] + out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts? value + ) + { + value = + this.Value + as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +1802,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 +1825,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 +1848,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 +1871,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 +1894,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 +1917,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 +1943,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 +1966,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 +1989,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 +2012,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 +2035,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 +2058,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 +2081,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. /// /// /// @@ -1925,24 +2105,50 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocat /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] + out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance? value + ) + { + value = + this.Value as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with 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.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum` + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum? value + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] + out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance? value ) { - value = this.Value as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum; + value = this.Value as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance; return value != null; } @@ -1950,7 +2156,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. /// /// /// @@ -1973,7 +2179,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 +2202,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 +2225,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 +2236,40 @@ 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) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} /// ); /// /// @@ -2081,6 +2289,7 @@ public void Switch( System::Action newFloatingPackageWithAllocation, System::Action newFloatingUnitWithPercent, System::Action newFloatingMatrixWithAllocation, + System::Action matrixWithThresholdDiscounts, System::Action newFloatingTieredWithProration, System::Action newFloatingUnitWithProration, System::Action newFloatingGroupedAllocation, @@ -2095,7 +2304,8 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -2145,6 +2355,9 @@ public void Switch( case NewFloatingMatrixWithAllocationPrice value: newFloatingMatrixWithAllocation(value); break; + case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case NewFloatingTieredWithProrationPrice value: newFloatingTieredWithProration(value); break; @@ -2187,8 +2400,11 @@ public void Switch( case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value: - minimum(value); + case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value: + meteredAllowance(value); break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); @@ -2210,7 +2426,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 +2437,40 @@ 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) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} /// ); /// /// @@ -2278,6 +2496,10 @@ public T Match( System::Func newFloatingPackageWithAllocation, System::Func newFloatingUnitWithPercent, System::Func newFloatingMatrixWithAllocation, + System::Func< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts, + T + > matrixWithThresholdDiscounts, System::Func newFloatingTieredWithProration, System::Func newFloatingUnitWithProration, System::Func newFloatingGroupedAllocation, @@ -2310,7 +2532,14 @@ public T Match( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, + System::Func< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance, + T + > dailyCreditAllowance, + System::Func< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance, + T + > meteredAllowance, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2335,6 +2564,8 @@ public T Match( NewFloatingPackageWithAllocationPrice value => newFloatingPackageWithAllocation(value), NewFloatingUnitWithPercentPrice value => newFloatingUnitWithPercent(value), NewFloatingMatrixWithAllocationPrice value => newFloatingMatrixWithAllocation(value), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts value => + matrixWithThresholdDiscounts(value), NewFloatingTieredWithProrationPrice value => newFloatingTieredWithProration(value), NewFloatingUnitWithProrationPrice value => newFloatingUnitWithProration(value), NewFloatingGroupedAllocationPrice value => newFloatingGroupedAllocation(value), @@ -2356,7 +2587,10 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value => minimum(value), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value => + dailyCreditAllowance(value), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value => + meteredAllowance(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value => percent(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value => eventOutput( @@ -2424,6 +2658,10 @@ public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationP NewFloatingMatrixWithAllocationPrice value ) => new(value); + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts value + ) => new(value); + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingTieredWithProrationPrice value ) => new(value); @@ -2481,7 +2719,11 @@ PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation ) => new(value); public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value ) => new(value); public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( @@ -2529,6 +2771,7 @@ public override void Validate() (newFloatingPackageWithAllocation) => newFloatingPackageWithAllocation.Validate(), (newFloatingUnitWithPercent) => newFloatingUnitWithPercent.Validate(), (newFloatingMatrixWithAllocation) => newFloatingMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (newFloatingTieredWithProration) => newFloatingTieredWithProration.Validate(), (newFloatingUnitWithProration) => newFloatingUnitWithProration.Validate(), (newFloatingGroupedAllocation) => newFloatingGroupedAllocation.Validate(), @@ -2547,17 +2790,18 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +2809,53 @@ public override int GetHashCode() } 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, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts _ => + 14, + NewFloatingTieredWithProrationPrice _ => 15, + NewFloatingUnitWithProrationPrice _ => 16, + NewFloatingGroupedAllocationPrice _ => 17, + NewFloatingBulkWithProrationPrice _ => 18, + NewFloatingGroupedWithProratedMinimumPrice _ => 19, + NewFloatingGroupedWithMeteredMinimumPrice _ => 20, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds _ => 21, + NewFloatingMatrixWithDisplayNamePrice _ => 22, + NewFloatingGroupedTieredPackagePrice _ => 23, + NewFloatingMaxGroupTieredPackagePrice _ => 24, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 25, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 26, + NewFloatingCumulativeGroupedBulkPrice _ => 27, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation _ => 28, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance _ => 29, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance _ => 30, + NewFloatingMinimumCompositePrice _ => 31, + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent _ => 32, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput _ => 33, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceConverter @@ -2600,12 +2890,10 @@ JsonSerializerOptions 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 +2910,10 @@ JsonSerializerOptions 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 +2930,10 @@ JsonSerializerOptions 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 +2951,10 @@ JsonSerializerOptions 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 +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 } @@ -2711,12 +2991,10 @@ JsonSerializerOptions 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 +3012,10 @@ JsonSerializerOptions 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 +3032,10 @@ JsonSerializerOptions 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 +3053,10 @@ JsonSerializerOptions 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 +3073,10 @@ JsonSerializerOptions 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 +3094,10 @@ JsonSerializerOptions 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 +3115,10 @@ JsonSerializerOptions 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 +3135,10 @@ JsonSerializerOptions 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 +3156,31 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -2915,12 +3198,10 @@ JsonSerializerOptions 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 +3219,10 @@ JsonSerializerOptions 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 +3240,10 @@ JsonSerializerOptions 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 +3261,10 @@ JsonSerializerOptions 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 +3282,10 @@ JsonSerializerOptions 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 +3303,10 @@ JsonSerializerOptions 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 +3324,10 @@ JsonSerializerOptions 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 +3345,10 @@ JsonSerializerOptions 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 +3366,10 @@ JsonSerializerOptions 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 +3387,10 @@ JsonSerializerOptions 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 +3408,10 @@ JsonSerializerOptions 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 +3429,10 @@ JsonSerializerOptions 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 +3450,10 @@ JsonSerializerOptions 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 +3471,52 @@ JsonSerializerOptions 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } return new(element); } - case "minimum": + case "metered_allowance": { try { var deserialized = - JsonSerializer.Deserialize( + 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 +3533,10 @@ JsonSerializerOptions 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 +3554,10 @@ JsonSerializerOptions 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 +3575,10 @@ JsonSerializerOptions 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 +3840,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3901,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3628,10 +3910,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 +4026,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 +4122,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 +4218,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 +4399,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 +4420,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 +4440,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 +4451,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4187,7 +4481,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 +4492,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4250,10 +4544,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 +4555,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +4603,10 @@ JsonSerializerOptions 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 +4623,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4351,11 +4654,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts : JsonModel { /// @@ -4363,7 +4666,7 @@ public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceG /// public required ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > Cadence { get @@ -4372,7 +4675,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence > >("cadence"); } @@ -4393,31 +4696,31 @@ public required string Currency } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for matrix_with_threshold_discounts pricing /// - public required string ItemID + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// @@ -4505,12 +4808,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4587,6 +4890,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4613,12 +4929,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.Currency; - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { @@ -4635,31 +4951,35 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts( FrozenDictionary rawData ) { @@ -4667,8 +4987,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4676,14 +4996,14 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds.FromRawUnchecked( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscounts.FromRawUnchecked( rawData ); } @@ -4692,9 +5012,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceConverter) + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadenceConverter) )] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence { Annual, SemiAnnual, @@ -4704,10 +5024,10 @@ public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMa Custom, } -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4716,19 +5036,2006 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual, "semi_annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.SemiAnnual, "monthly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Monthly, "quarterly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Custom, + _ => + (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Annual => + "annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.SemiAnnual => + "semi_annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Monthly => + "monthly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Quarterly => + "quarterly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.OneTime => + "one_time", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfigConverter) +)] +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + JsonElement element + ) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMatrixWithThresholdDiscountsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds() + { + 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 + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceConverter) +)] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly, "one_time" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime, "custom" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => + (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual => + "annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + "semi_annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly => + "monthly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly => + "quarterly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime => + "one_time", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.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< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) +)] +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + JsonElement element + ) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.CumulativeGroupedAllocationConfig.Validate(); + _ = this.Currency; + _ = 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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation() + { + 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 + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceConverter) +)] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom, _ => - (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence)( + (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence)( -1 ), }; @@ -4736,7 +7043,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -4744,17 +7051,17 @@ JsonSerializerOptions options writer, value switch { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual => "annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Monthly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Quarterly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.OneTime => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Custom => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -4766,89 +7073,92 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( - priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -4857,7 +7167,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -4865,8 +7175,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4874,22 +7184,22 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter) )] -public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4907,7 +7217,7 @@ public JsonElement Json } } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4916,7 +7226,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThre this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4925,7 +7235,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThre this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -4936,7 +7246,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 +7267,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 +7287,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 +7298,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5009,7 +7319,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -5018,7 +7328,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 +7339,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5045,16 +7355,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5073,18 +7383,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5092,13 +7402,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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5127,12 +7450,10 @@ JsonSerializerOptions 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 +7470,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5163,7 +7482,7 @@ JsonSerializerOptions options } default: { - return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -5172,7 +7491,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5182,11 +7501,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance : JsonModel { /// @@ -5194,7 +7513,7 @@ public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceC /// public required ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > Cadence { get @@ -5203,7 +7522,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > >("cadence"); } @@ -5211,31 +7530,31 @@ public required ApiEnum< } /// - /// Configuration for cumulative_grouped_allocation pricing + /// An ISO 4217 currency string for which this price is billed in. /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("currency", value); } } /// - /// An ISO 4217 currency string for which this price is billed in. + /// Configuration for daily_credit_allowance pricing /// - public required string Currency + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -5336,12 +7655,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5418,6 +7737,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5443,13 +7775,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -5466,31 +7798,35 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( FrozenDictionary rawData ) { @@ -5498,8 +7834,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5507,14 +7843,14 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation.FromRawUnchecked( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance.FromRawUnchecked( rawData ); } @@ -5523,9 +7859,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceConverter) + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceConverter) )] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -5535,10 +7871,10 @@ public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupe Custom, } -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5547,27 +7883,26 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, "semi_annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual, "monthly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly, "quarterly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly, "one_time" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime, "custom" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom, - _ => - (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence)( - -1 - ), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom, + _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -5575,17 +7910,17 @@ JsonSerializerOptions options writer, value switch { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual => "annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly => "monthly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly => "quarterly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime => "one_time", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -5597,58 +7932,195 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -5663,23 +8135,24 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) : base( - priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -5688,7 +8161,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -5696,8 +8169,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5705,22 +8178,22 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter) + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigConverter) )] -public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5738,7 +8211,7 @@ public JsonElement Json } } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5747,7 +8220,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllo this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5756,7 +8229,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllo this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( JsonElement element ) { @@ -5767,7 +8240,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 +8261,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 +8281,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 +8292,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5840,7 +8313,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -5849,7 +8322,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 +8333,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5876,16 +8349,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5904,18 +8377,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5923,13 +8396,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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5958,12 +8444,10 @@ JsonSerializerOptions 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 +8464,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5994,7 +8476,7 @@ JsonSerializerOptions options } default: { - return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig( + return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( element ); } @@ -6003,7 +8485,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6013,25 +8495,29 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum : JsonModel +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6064,18 +8550,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig MinimumConfig + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -6163,12 +8649,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? ConversionRateConfig + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6245,6 +8731,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,8 +8771,13 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -6288,31 +8792,35 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( FrozenDictionary rawData ) { @@ -6320,8 +8828,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6329,20 +8837,25 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum.FromRawUnchecked(rawData); + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter))] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadenceConverter) +)] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -6352,10 +8865,10 @@ public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Custom, } -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6363,22 +8876,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + "annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, "semi_annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual, - "monthly" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly, "quarterly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly, "one_time" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime, - "custom" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom, - _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence)(-1), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime, + "custom" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom, + _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -6386,17 +8902,17 @@ JsonSerializerOptions options writer, value switch { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual => "annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly => "monthly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly => "quarterly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime => "one_time", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -6408,39 +8924,104 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. + /// + public required string AllowanceGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumAmount + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -6449,25 +9030,35 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig() { } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig() + { } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig) { } + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + ) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -6476,7 +9067,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( FrozenDictionary rawData ) { @@ -6484,40 +9075,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig.FromRawUnchecked( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigConverter) + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfigConverter) )] -public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6535,7 +9117,7 @@ public JsonElement Json } } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6544,7 +9126,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRate this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6553,7 +9135,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRate this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -6564,7 +9146,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. /// /// /// @@ -6585,7 +9167,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. /// /// /// @@ -6605,7 +9187,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. /// /// @@ -6616,8 +9198,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6637,7 +9219,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig" ); } } @@ -6646,7 +9228,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. /// /// @@ -6657,8 +9239,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6673,16 +9255,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6701,18 +9283,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6720,13 +9302,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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6755,12 +9350,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6777,12 +9370,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6791,7 +9382,7 @@ JsonSerializerOptions options } default: { - return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( element ); } @@ -6800,7 +9391,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -7042,6 +9633,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7085,6 +9689,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7093,10 +9698,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( IReadOnlyDictionary rawData @@ -7237,10 +9845,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 +9948,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 +9969,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 +9989,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 +10000,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7419,7 +10030,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 +10041,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7482,10 +10093,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 +10104,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10152,10 @@ JsonSerializerOptions 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 +10172,10 @@ JsonSerializerOptions 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 +10439,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10500,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7875,10 +10509,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 +10692,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 +10797,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 +10818,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 +10838,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 +10849,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8239,7 +10879,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 +10890,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8302,10 +10942,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 +10953,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +11001,10 @@ JsonSerializerOptions 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 +11021,10 @@ JsonSerializerOptions 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..89c8c4b2b 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; @@ -1636,6 +1701,7 @@ public string ItemID newSubscriptionPackageWithAllocation: (x) => x.ItemID, newSubscriptionUnitWithPercent: (x) => x.ItemID, newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, tieredWithProration: (x) => x.ItemID, newSubscriptionUnitWithProration: (x) => x.ItemID, newSubscriptionGroupedAllocation: (x) => x.ItemID, @@ -1650,7 +1716,8 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1677,6 +1744,7 @@ public string Name newSubscriptionPackageWithAllocation: (x) => x.Name, newSubscriptionUnitWithPercent: (x) => x.Name, newSubscriptionMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, tieredWithProration: (x) => x.Name, newSubscriptionUnitWithProration: (x) => x.Name, newSubscriptionGroupedAllocation: (x) => x.Name, @@ -1691,7 +1759,8 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1718,6 +1787,7 @@ public string? BillableMetricID newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, tieredWithProration: (x) => x.BillableMetricID, newSubscriptionUnitWithProration: (x) => x.BillableMetricID, newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, @@ -1732,7 +1802,8 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1759,6 +1830,7 @@ public bool? BilledInAdvance newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, tieredWithProration: (x) => x.BilledInAdvance, newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, @@ -1773,7 +1845,8 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1800,6 +1873,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, tieredWithProration: (x) => x.BillingCycleConfiguration, newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, @@ -1814,7 +1888,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1841,6 +1916,7 @@ public double? ConversionRate newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, newSubscriptionUnitWithPercent: (x) => x.ConversionRate, newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, tieredWithProration: (x) => x.ConversionRate, newSubscriptionUnitWithProration: (x) => x.ConversionRate, newSubscriptionGroupedAllocation: (x) => x.ConversionRate, @@ -1855,7 +1931,8 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1882,6 +1959,7 @@ public string? Currency newSubscriptionPackageWithAllocation: (x) => x.Currency, newSubscriptionUnitWithPercent: (x) => x.Currency, newSubscriptionMatrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, tieredWithProration: (x) => x.Currency, newSubscriptionUnitWithProration: (x) => x.Currency, newSubscriptionGroupedAllocation: (x) => x.Currency, @@ -1896,7 +1974,8 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1923,6 +2002,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, tieredWithProration: (x) => x.DimensionalPriceConfiguration, newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -1939,7 +2019,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1966,6 +2047,7 @@ public string? ExternalPriceID newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, tieredWithProration: (x) => x.ExternalPriceID, newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, @@ -1980,7 +2062,8 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2007,6 +2090,7 @@ public double? FixedPriceQuantity newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, tieredWithProration: (x) => x.FixedPriceQuantity, newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, @@ -2021,7 +2105,8 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2048,6 +2133,7 @@ public string? InvoiceGroupingKey newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, tieredWithProration: (x) => x.InvoiceGroupingKey, newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, @@ -2062,7 +2148,8 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2089,6 +2176,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, tieredWithProration: (x) => x.InvoicingCycleConfiguration, newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -2104,7 +2192,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2112,6 +2201,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -2131,6 +2263,7 @@ public string? ReferenceID newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, newSubscriptionUnitWithPercent: (x) => x.ReferenceID, newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + matrixWithThresholdDiscounts: (x) => x.ReferenceID, tieredWithProration: (x) => x.ReferenceID, newSubscriptionUnitWithProration: (x) => x.ReferenceID, newSubscriptionGroupedAllocation: (x) => x.ReferenceID, @@ -2145,7 +2278,8 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2171,10 +2305,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 +2371,13 @@ public Price(NewSubscriptionMatrixWithAllocationPrice value, JsonElement? elemen this._element = element; } - public Price( - global::Orb.Models.Subscriptions.TieredWithProration value, - JsonElement? element = null - ) + public Price(MatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2279,10 +2413,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 +2461,19 @@ public Price(NewSubscriptionCumulativeGroupedBulkPrice value, JsonElement? eleme this._element = element; } - public Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public Price(DailyCreditAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Subscriptions.Minimum value, JsonElement? element = null) + public Price(MeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2351,13 +2485,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 +2506,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 +2527,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 +2550,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 +2569,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 +2592,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 +2615,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 +2638,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 +2661,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 +2684,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 +2707,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 +2730,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 +2753,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 +2776,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 +2799,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 +2820,45 @@ 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` + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `MatrixWithThresholdDiscounts` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.TieredWithProration? value + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out MatrixWithThresholdDiscounts? value ) { - value = this.Value as global::Orb.Models.Subscriptions.TieredWithProration; + value = this.Value as MatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `TieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) + { + value = this.Value as TieredWithProration; return value != null; } @@ -2713,7 +2866,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 +2889,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 +2912,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 +2935,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 +2958,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 +2979,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 +3004,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 +3027,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 +3050,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 +3073,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 +3096,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 +3119,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 +3140,66 @@ 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 + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Subscriptions.CumulativeGroupedAllocation; + value = this.Value as CumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// 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` + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `DailyCreditAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.Minimum? value - ) + public bool TryPickDailyCreditAllowance([NotNullWhen(true)] out DailyCreditAllowance? value) + { + value = this.Value as DailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `MeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance([NotNullWhen(true)] out MeteredAllowance? value) { - value = this.Value as global::Orb.Models.Subscriptions.Minimum; + value = this.Value as MeteredAllowance; return value != null; } @@ -3035,7 +3207,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 +3228,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 +3282,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3324,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 +3335,26 @@ public void Switch( System::Action newSubscriptionPackageWithAllocation, System::Action newSubscriptionUnitWithPercent, System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, + System::Action matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -3196,7 +3368,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 +3401,10 @@ public void Switch( case NewSubscriptionMatrixWithAllocationPrice value: newSubscriptionMatrixWithAllocation(value); break; - case global::Orb.Models.Subscriptions.TieredWithProration value: + case MatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; + case TieredWithProration value: tieredWithProration(value); break; case NewSubscriptionUnitWithProrationPrice value: @@ -3247,7 +3422,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 +3443,22 @@ 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); + case DailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case MeteredAllowance value: + meteredAllowance(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 +3470,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 +3481,40 @@ 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) => {...}, + /// (MatrixWithThresholdDiscounts 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) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3523,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 +3546,8 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func matrixWithThresholdDiscounts, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3559,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 +3584,12 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice, T > newSubscriptionCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -3421,7 +3597,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 +3615,8 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( value ), - global::Orb.Models.Subscriptions.TieredWithProration value => tieredWithProration( - value - ), + MatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), + TieredWithProration value => tieredWithProration(value), NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), @@ -3449,8 +3624,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 +3641,101 @@ 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), + DailyCreditAllowance value => dailyCreditAllowance(value), + MeteredAllowance value => meteredAllowance(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(MatrixWithThresholdDiscounts value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithProratedMinimumPrice 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(NewSubscriptionGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator Price(NewSubscriptionMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithUnitPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithTieredPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Minimum value - ) => new(value); + public static implicit operator Price(DailyCreditAllowance value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(MeteredAllowance 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(NewSubscriptionMinimumCompositePrice 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(Percent 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 @@ -3638,6 +3770,7 @@ public override void Validate() newSubscriptionPackageWithAllocation.Validate(), (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (tieredWithProration) => tieredWithProration.Validate(), (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), @@ -3659,17 +3792,18 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +3811,57 @@ public override int GetHashCode() } 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, + MatrixWithThresholdDiscounts _ => 14, + TieredWithProration _ => 15, + NewSubscriptionUnitWithProrationPrice _ => 16, + NewSubscriptionGroupedAllocationPrice _ => 17, + NewSubscriptionBulkWithProrationPrice _ => 18, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 19, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 20, + GroupedWithMinMaxThresholds _ => 21, + NewSubscriptionMatrixWithDisplayNamePrice _ => 22, + NewSubscriptionGroupedTieredPackagePrice _ => 23, + NewSubscriptionMaxGroupTieredPackagePrice _ => 24, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 25, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 26, + NewSubscriptionCumulativeGroupedBulkPrice _ => 27, + CumulativeGroupedAllocation _ => 28, + DailyCreditAllowance _ => 29, + MeteredAllowance _ => 30, + NewSubscriptionMinimumCompositePrice _ => 31, + Percent _ => 32, + EventOutput _ => 33, + _ => -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 +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 } @@ -3733,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 } @@ -3755,12 +3930,10 @@ JsonSerializerOptions 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 +3944,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 +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 } @@ -3822,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 } @@ -3845,12 +4011,10 @@ JsonSerializerOptions 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 +4032,10 @@ JsonSerializerOptions 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 +4053,10 @@ JsonSerializerOptions 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 +4074,10 @@ JsonSerializerOptions 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 +4095,10 @@ JsonSerializerOptions 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 +4116,10 @@ JsonSerializerOptions 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 +4137,10 @@ JsonSerializerOptions 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 +4158,30 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -4022,19 +4192,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 +4219,10 @@ JsonSerializerOptions 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 +4240,10 @@ JsonSerializerOptions 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 +4261,10 @@ JsonSerializerOptions 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 +4282,10 @@ JsonSerializerOptions 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 +4303,10 @@ JsonSerializerOptions 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 +4317,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 +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 } @@ -4213,12 +4365,10 @@ JsonSerializerOptions 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 +4386,10 @@ JsonSerializerOptions 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 +4407,10 @@ JsonSerializerOptions 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 +4428,10 @@ JsonSerializerOptions 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 +4449,10 @@ JsonSerializerOptions 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 +4463,56 @@ 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 "daily_credit_allowance": { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4374,12 +4530,10 @@ JsonSerializerOptions 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 +4544,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 +4561,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 +4576,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 +4606,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 +4714,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); } } @@ -4681,6 +4808,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4743,6 +4883,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4752,8 +4893,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 +4914,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 +4956,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 +4987,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 +5006,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 +5015,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 +5064,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 +5083,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 +5138,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 +5157,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 +5171,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 +5192,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 +5202,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 +5233,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 +5272,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 +5293,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 +5313,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 +5324,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5236,7 +5354,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 +5365,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5268,13 +5386,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 +5413,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 +5424,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 +5471,10 @@ JsonSerializerOptions 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 +5491,10 @@ JsonSerializerOptions 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 +5503,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 ) { @@ -5395,26 +5519,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProration, - global::Orb.Models.Subscriptions.TieredWithProrationFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class TieredWithProration : JsonModel +public sealed record class MatrixWithThresholdDiscounts : 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 + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -5434,44 +5552,44 @@ public required string ItemID } /// - /// The pricing model type + /// Configuration for matrix_with_threshold_discounts pricing /// - public JsonElement ModelType + public required MatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// - /// The name of the price. + /// The pricing model type /// - public required string Name + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("model_type", value); } } /// - /// Configuration for tiered_with_proration pricing + /// The name of the price. /// - public required global::Orb.Models.Subscriptions.TieredWithProrationConfig TieredWithProrationConfig + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("name", value); } } /// @@ -5533,12 +5651,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 MatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5629,6 +5747,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5669,17 +5800,17 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -5691,37 +5822,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public MatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public TieredWithProration( - global::Orb.Models.Subscriptions.TieredWithProration tieredWithProration - ) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscounts(MatrixWithThresholdDiscounts matrixWithThresholdDiscounts) + : base(matrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + MatrixWithThresholdDiscounts(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( + /// + public static MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5729,20 +5862,19 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( + public MatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProration.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscounts.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(MatrixWithThresholdDiscountsCadenceConverter))] +public enum MatrixWithThresholdDiscountsCadence { Annual, SemiAnnual, @@ -5752,10 +5884,10 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class MatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationCadence Read( + public override MatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5763,19 +5895,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" => MatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => MatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => MatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => MatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => MatrixWithThresholdDiscountsCadence.OneTime, + "custom" => MatrixWithThresholdDiscountsCadence.Custom, + _ => (MatrixWithThresholdDiscountsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationCadence value, + MatrixWithThresholdDiscountsCadence value, JsonSerializerOptions options ) { @@ -5783,14 +5915,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", + MatrixWithThresholdDiscountsCadence.Annual => "annual", + MatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + MatrixWithThresholdDiscountsCadence.Monthly => "monthly", + MatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + MatrixWithThresholdDiscountsCadence.OneTime => "one_time", + MatrixWithThresholdDiscountsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5801,120 +5931,166 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for matrix_with_threshold_discounts pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfig, - global::Orb.Models.Subscriptions.TieredWithProrationConfigFromRaw + MatrixWithThresholdDiscountsConfig, + MatrixWithThresholdDiscountsConfigFromRaw >) )] -public sealed record class TieredWithProrationConfig : JsonModel +public sealed record class MatrixWithThresholdDiscountsConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Unit price used for usage that does not match any defined matrix cell. /// - public required IReadOnlyList Tiers + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("matrix_values"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>( + "threshold_discount_groups" + ); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); } } /// public override void Validate() { - foreach (var item in this.Tiers) + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) { item.Validate(); } } - public TieredWithProrationConfig() { } + public MatrixWithThresholdDiscountsConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Subscriptions.TieredWithProrationConfig tieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithThresholdDiscountsConfig( + MatrixWithThresholdDiscountsConfig matrixWithThresholdDiscountsConfig ) - : base(tieredWithProrationConfig) { } + : base(matrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public MatrixWithThresholdDiscountsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + MatrixWithThresholdDiscountsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + /// + public static MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class MatrixWithThresholdDiscountsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + public MatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => MatrixWithThresholdDiscountsConfig.FromRawUnchecked(rawData); } -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier, - global::Orb.Models.Subscriptions.TieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : JsonModel { - /// - /// Inclusive tier starting value - /// - public required string TierLowerBound + public required string FirstDimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("first_dimension_value"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("first_dimension_value", value); } } - /// - /// Amount per unit - /// public required string UnitAmount { get @@ -5925,35 +6101,157 @@ public required string UnitAmount init { this._rawData.Set("unit_amount", 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.TierLowerBound; + _ = this.FirstDimensionValue; _ = this.UnitAmount; + _ = this.SecondDimensionValue; } - public TieredWithProrationConfigTier() { } + public MatrixValue() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public MatrixValue(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + MatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixValueFromRaw : IFromRawJson +{ + /// + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdDiscountGroup : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public ThresholdDiscountGroup() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdDiscountGroup(ThresholdDiscountGroup thresholdDiscountGroup) + : base(thresholdDiscountGroup) { } +#pragma warning restore CS8618 + + public ThresholdDiscountGroup(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ThresholdDiscountGroup(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static ThresholdDiscountGroup FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5961,19 +6259,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class ThresholdDiscountGroupFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + public ThresholdDiscountGroup FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => ThresholdDiscountGroup.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfigConverter) -)] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class MatrixWithThresholdDiscountsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5990,7 +6285,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5999,7 +6294,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6008,7 +6303,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public MatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) { this._element = element; } @@ -6017,7 +6312,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 +6333,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 +6353,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 +6364,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6090,7 +6385,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of MatrixWithThresholdDiscountsConversionRateConfig" ); } } @@ -6099,7 +6394,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 +6405,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6126,16 +6421,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 MatrixWithThresholdDiscountsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator MatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6154,18 +6449,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 MatrixWithThresholdDiscountsConversionRateConfig" ); } 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(MatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6173,13 +6466,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 MatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? Read( + public override MatrixWithThresholdDiscountsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6208,12 +6514,10 @@ JsonSerializerOptions 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 +6534,10 @@ JsonSerializerOptions 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 +6546,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( - element - ); + return new MatrixWithThresholdDiscountsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig value, + MatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6261,45 +6561,22 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[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.GroupedWithMinMaxThresholdsCadence - > 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 global::Orb.Models.Subscriptions.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); } } /// @@ -6341,6 +6618,21 @@ public required string 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. /// @@ -6400,12 +6692,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 TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6496,6 +6788,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6535,18 +6840,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(); @@ -6558,37 +6863,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public TieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public TieredWithProration(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) + TieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6596,22 +6903,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence { Annual, SemiAnnual, @@ -6621,10 +6924,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6632,35 +6934,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" => 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.GroupedWithMinMaxThresholdsCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -6668,18 +6954,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", + 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)) ), @@ -6690,122 +6970,172 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class TieredWithProrationConfig : 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 + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string MinimumCharge + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } - init { this._rawData.Set("minimum_charge", value); } - } - - /// - /// The base price charged per group - /// - public required string PerUnitRate - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public GroupedWithMinMaxThresholdsConfig() { } + public TieredWithProrationConfig() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public TieredWithProrationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + TieredWithProrationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } +/// +/// Configuration for a single tiered with proration tier +/// [JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(JsonModelConverter) )] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +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; @@ -6822,7 +7152,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6831,7 +7161,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6840,7 +7170,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public TieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -6849,7 +7179,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 +7200,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 +7220,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 +7231,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6922,7 +7252,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of TieredWithProrationConversionRateConfig" ); } } @@ -6931,7 +7261,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 +7272,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6958,16 +7288,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 TieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6986,18 +7316,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 TieredWithProrationConversionRateConfig" ); } 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(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7005,13 +7333,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 TieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7040,12 +7381,10 @@ JsonSerializerOptions 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 +7401,10 @@ JsonSerializerOptions 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 +7413,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7094,44 +7429,38 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class CumulativeGroupedAllocation : JsonModel +public sealed record class GroupedWithMinMaxThresholds : 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); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required GroupedWithMinMaxThresholdsConfig 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); } } /// @@ -7232,12 +7561,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 GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7328,6 +7657,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7367,12 +7709,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") ) ) { @@ -7390,37 +7732,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(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) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7428,22 +7772,19 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadenceConverter) -)] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -7453,10 +7794,10 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7464,35 +7805,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" => 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.CumulativeGroupedAllocationCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -7500,18 +7825,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", + 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)) ), @@ -7522,99 +7841,102 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : 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 GroupedWithMinMaxThresholdsConfig() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) - : base(cumulativeGroupedAllocationConfig) { } + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,22 +7944,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7654,7 +7970,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7663,7 +7979,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7672,7 +7988,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -7681,7 +7997,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 +8018,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 +8038,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 +8049,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7754,7 +8070,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -7763,7 +8079,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 +8090,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7790,16 +8106,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 GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7818,18 +8134,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 GroupedWithMinMaxThresholdsConversionRateConfig" ); } 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(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7837,13 +8151,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 GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7872,12 +8199,10 @@ JsonSerializerOptions 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 +8219,10 @@ JsonSerializerOptions 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 +8231,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -7926,52 +8247,51 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Minimum, - global::Orb.Models.Subscriptions.MinimumFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class Minimum : JsonModel +public sealed record class CumulativeGroupedAllocation : 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 CumulativeGroupedAllocationConfig 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.Subscriptions.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); } } /// @@ -8059,12 +8379,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8155,6 +8475,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -8194,9 +8527,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"); } @@ -8212,35 +8550,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public Minimum(global::Orb.Models.Subscriptions.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public Minimum(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 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8248,19 +8590,19 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Minimum.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -8270,9 +8612,10 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override MinimumCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8280,19 +8623,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" => 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, - MinimumCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -8300,12 +8643,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", + 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)) ), @@ -8316,101 +8659,119 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumConfig, - global::Orb.Models.Subscriptions.MinimumConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class MinimumConfig : JsonModel +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(global::Orb.Models.Subscriptions.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 global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( + /// + 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 global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8427,7 +8788,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8436,7 +8797,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8445,7 +8806,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -8454,7 +8815,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 +8836,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 +8856,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 +8867,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8527,7 +8888,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -8536,7 +8897,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 +8908,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8563,16 +8924,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8591,16 +8952,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 CumulativeGroupedAllocationConversionRateConfig" ); } 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(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8608,12 +8969,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8642,12 +9017,10 @@ JsonSerializerOptions 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 +9037,10 @@ JsonSerializerOptions 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 +9049,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -8693,29 +9064,39 @@ 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 DailyCreditAllowance : 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 daily_credit_allowance pricing + /// + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); + } + init { this._rawData.Set("daily_credit_allowance_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -8755,21 +9136,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 +9195,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 DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8925,6 +9291,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9343,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8982,35 +9366,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public Percent(global::Orb.Models.Subscriptions.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Percent FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9018,19 +9406,19 @@ IReadOnlyDictionary rawData } } -class PercentFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Percent FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Percent.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -9040,10 +9428,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9051,19 +9438,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" => DailyCreditAllowanceCadence.Annual, + "semi_annual" => DailyCreditAllowanceCadence.SemiAnnual, + "monthly" => DailyCreditAllowanceCadence.Monthly, + "quarterly" => DailyCreditAllowanceCadence.Quarterly, + "one_time" => DailyCreditAllowanceCadence.OneTime, + "custom" => DailyCreditAllowanceCadence.Custom, + _ => (DailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -9071,12 +9458,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", + DailyCreditAllowanceCadence.Annual => "annual", + DailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + DailyCreditAllowanceCadence.Monthly => "monthly", + DailyCreditAllowanceCadence.Quarterly => "quarterly", + DailyCreditAllowanceCadence.OneTime => "one_time", + DailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9087,96 +9474,256 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PercentConfig, - global::Orb.Models.Subscriptions.PercentConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class PercentConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required double Percent + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public PercentConfig() { } + public DailyCreditAllowanceConfig() { } - public PercentConfig(global::Orb.Models.Subscriptions.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class DailyCreditAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + public DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PercentConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + DailyCreditAllowanceConfigMatrixValue, + DailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class DailyCreditAllowanceConfigMatrixValue : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + /// + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. + /// + public required IReadOnlyList DimensionValues { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimension_values"); } - } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } - public PercentConversionRateConfig( + /// + /// Credits charged per unit of usage matching the specified dimension_values + /// + 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.DimensionValues; + _ = this.UnitAmount; + } + + public DailyCreditAllowanceConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue + ) + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceConfigMatrixValue(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9185,7 +9732,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9194,7 +9741,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -9203,7 +9750,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 +9771,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 +9791,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 +9802,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9276,7 +9823,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -9285,7 +9832,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 +9843,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9312,16 +9859,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9340,16 +9887,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9357,13 +9904,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9392,12 +9952,10 @@ JsonSerializerOptions 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 +9972,10 @@ JsonSerializerOptions 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 +9984,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.PercentConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9443,55 +9999,50 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutput, - global::Orb.Models.Subscriptions.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : 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.Subscriptions.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. + /// Configuration for metered_allowance pricing /// - public required string ItemID + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -9579,12 +10130,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? ConversionRateConfig + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9675,6 +10226,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -9714,12 +10278,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("event_output") + JsonSerializer.SerializeToElement("metered_allowance") ) ) { @@ -9737,35 +10301,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public EventOutput(global::Orb.Models.Subscriptions.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9773,19 +10341,18 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutput.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -9795,10 +10362,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9806,19 +10372,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.EventOutputCadence.Custom, - _ => (global::Orb.Models.Subscriptions.EventOutputCadence)(-1), + "annual" => MeteredAllowanceCadence.Annual, + "semi_annual" => MeteredAllowanceCadence.SemiAnnual, + "monthly" => MeteredAllowanceCadence.Monthly, + "quarterly" => MeteredAllowanceCadence.Quarterly, + "one_time" => MeteredAllowanceCadence.OneTime, + "custom" => MeteredAllowanceCadence.Custom, + _ => (MeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -9826,12 +10392,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.EventOutputCadence.Annual => "annual", - global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.EventOutputCadence.Custom => "custom", + MeteredAllowanceCadence.Annual => "annual", + MeteredAllowanceCadence.SemiAnnual => "semi_annual", + MeteredAllowanceCadence.Monthly => "monthly", + MeteredAllowanceCadence.Quarterly => "quarterly", + MeteredAllowanceCadence.OneTime => "one_time", + MeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9842,110 +10408,161 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutputConfig, - global::Orb.Models.Subscriptions.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public required string UnitRatingKey + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("allowance_grouping_value"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("allowance_grouping_value", 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 grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. /// - public string? DefaultUnitRate + public required string ConsumptionGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("consumption_grouping_value"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("consumption_grouping_value", 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. + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. /// - public string? GroupingKey + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullClass("grouping_key"); } init { this._rawData.Set("grouping_key", value); } } + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); + } + } + + /// + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + /// + public string? ConsumptionDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); + } + } + /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public EventOutputConfig() { } + public MeteredAllowanceConfig() { } - public EventOutputConfig(global::Orb.Models.Subscriptions.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; - } } -class EventOutputConfigFromRaw : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutputConfig.FromRawUnchecked(rawData); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9962,7 +10579,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9971,7 +10588,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9980,7 +10597,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -9989,7 +10606,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. /// /// /// @@ -10010,7 +10627,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. /// /// /// @@ -10030,7 +10647,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. /// /// @@ -10041,8 +10658,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10062,7 +10679,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -10071,7 +10688,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,8 +10699,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10098,16 +10715,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -10126,18 +10743,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 MeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10145,13 +10760,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10180,12 +10808,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10202,12 +10828,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10216,16 +10840,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - element - ); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -10233,449 +10855,558 @@ 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 Percent : JsonModel { - public override ExternalMarketplace Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence { - 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>("cadence"); + } + init { this._rawData.Set("cadence", value); } } - public override void Write( - Utf8JsonWriter writer, - ExternalMarketplace value, - JsonSerializerOptions options - ) + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - JsonSerializer.Serialize( - writer, - value switch - { - ExternalMarketplace.Google => "google", - ExternalMarketplace.Aws => "aws", - ExternalMarketplace.Azure => "azure", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel -{ /// - /// The id of the adjustment to remove on the subscription. + /// The pricing model type /// - public required string AdjustmentID + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("model_type", value); } } - /// - public override void Validate() + /// + /// The name of the price. + /// + public required string Name { - _ = this.AdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - public RemoveAdjustment() { } - - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } -#pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } -} - -class RemoveAdjustmentFromRaw : IFromRawJson -{ - /// - public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - RemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public string? ExternalPriceID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("conversion_rate", value); } } /// - /// The id of the price to remove on the subscription. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public string? PriceID + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("price_id", 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.ExternalPriceID; - _ = this.PriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(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] - RemovePrice(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 RemovePrice 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 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. + /// The property used to group this price on an invoice /// - public required ReplaceAdjustmentAdjustment Adjustment + public string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public required string ReplacesAdjustmentID + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - /// - public override void Validate() + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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 ReplaceAdjustment(IReadOnlyDictionary rawData) + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + 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 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] - ReplaceAdjustment(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class ReplaceAdjustmentFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the subscription. +/// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { - public object? Value { get; } = null; - - JsonElement? _element = null; + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public JsonElement Json +sealed class PercentCadenceConverter : JsonConverter +{ + public override PercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), + }; } - public string? Currency + public override void Write( + Utf8JsonWriter writer, + PercentCadence value, + JsonSerializerOptions options + ) { - get - { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency - ); - } + 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 + ); } +} - public bool? IsInvoiceLevel +/// +/// 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 { - 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.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Percent; } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public PercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 + + public PercentConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + PercentConfig(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + /// + public static 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 ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public PercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(JsonElement 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 . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewPercentageDiscount; + value = 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewUsageDiscount; + 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. - /// - /// - /// - /// 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. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// /// /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data @@ -10685,43 +11416,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 PercentConversionRateConfig" ); } } @@ -10730,7 +11446,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. /// /// @@ -10741,48 +11457,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 PercentConversionRateConfig" ), }; } - 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 PercentConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum 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 @@ -10799,22 +11501,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 PercentConversionRateConfig" ); } - 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10822,128 +11518,77 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 PercentConversionRateConfigConverter : JsonConverter { - public override ReplaceAdjustmentAdjustment? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; + string? conversionRateType; try { - adjustmentType = element.GetProperty("adjustment_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - adjustmentType = null; + conversionRateType = null; } - switch (adjustmentType) + switch (conversionRateType) { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "usage_discount": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); 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": + 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) - { - // 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) + catch (JsonException) { // ignore } @@ -10952,14 +11597,14 @@ JsonSerializerOptions options } default: { - return new ReplaceAdjustmentAdjustment(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -10967,1977 +11612,3695 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// - /// The id of the price on the plan to replace in the subscription. + /// 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 definition of a new allocation price to create and add to the subscription. + /// Configuration for event_output pricing /// - public NewAllocationPrice? AllocationPrice + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); + return this._rawData.GetNotNullClass("event_output_config"); } - init { this._rawData.Set("allocation_price", value); } + init { this._rawData.Set("event_output_config", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. + /// The id of the item the price will be associated with. /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("item_id"); } + init { this._rawData.Set("item_id", value); } } /// - /// The external price id of the price to add to the subscription. + /// The pricing model type /// - public string? ExternalPriceID + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The new quantity of the price, if the price is a fixed price. + /// The name of the price. /// - public double? FixedPriceQuantity + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("fixed_price_quantity", value); } + init { this._rawData.Set("name", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + public string? BillableMetricID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); + return this._rawData.GetNullableClass("billable_metric_id"); } - init { this._rawData.Set("maximum_amount", value); } + init { this._rawData.Set("billable_metric_id", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public bool? BilledInAdvance { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); + return this._rawData.GetNullableStruct("billed_in_advance"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("billed_in_advance", value); } } /// - /// New subscription price request body params. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public ReplacePricePrice? Price + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The id of the price to add to the subscription. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public string? PriceID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("conversion_rate", value); } } - /// - public override void Validate() + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public EventOutputConversionRateConfig? ConversionRateConfig { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + init { this._rawData.Set("conversion_rate_config", value); } } - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary rawData) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary 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 restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// An alias for the price. + /// + public string? ExternalPriceID { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } -} - -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); -} -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; + /// + /// The property used to group this price on 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 JsonElement Json + /// + /// Within each 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 this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string ItemID + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public string Name + /// + /// User-specified key/value pairs for the resource. Individual keys can be 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( - 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._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public string? BillableMetricID + /// + /// 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( - 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._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public bool? BilledInAdvance + /// + public override void Validate() { - get + this.Cadence.Validate(); + this.EventOutputConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { - 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 - ); + throw new OrbInvalidDataException("Invalid value given for constant"); } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + public EventOutput() { - get + 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 { - 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 - ); - } + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), + }; } - public double? ConversionRate + 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 { - 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._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); } + init { this._rawData.Set("unit_rating_key", value); } } - public string? Currency + /// + /// 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 { - 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._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); } + init { this._rawData.Set("default_unit_rate", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// 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 { - 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._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - public string? ExternalPriceID + /// + public override void Validate() { - 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.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public double? FixedPriceQuantity + public EventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 + + public EventOutputConfig(IReadOnlyDictionary rawData) { - 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._rawData = new(rawData); } - public string? InvoiceGroupingKey +#pragma warning disable CS8618 + [SetsRequiredMembers] + EventOutputConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static EventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public EventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +class EventOutputConfigFromRaw : IFromRawJson +{ + /// + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { get { - return 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 + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } - - public string? ReferenceID - { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) + public EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + public EventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + public EventOutputConversionRateConfig(JsonElement element) { - this.Value = value; this._element = element; } - 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.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - this.Value = value; - this._element = element; + value = this.Value as SharedUnitConversionRateConfig; + 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.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - this.Value = value; - this._element = element; + value = this.Value as SharedTieredConversionRateConfig; + return value != null; } - public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) { - this.Value = value; - this._element = element; + switch (this.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" + ); + } } - public ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value, - JsonElement? element = null + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered ) { - this.Value = value; - this._element = element; + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of EventOutputConversionRateConfig" + ), + }; } - public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator EventOutputConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - public ReplacePricePrice(NewSubscriptionGroupedTieredPrice 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() { - this.Value = value; - this._element = element; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of EventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public virtual bool Equals(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) + public override int GetHashCode() { - this.Value = value; - this._element = element; + return 0; } - public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - public ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) + int VariantIndex() { - this.Value = value; - this._element = element; + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null +sealed class EventOutputConversionRateConfigConverter + : JsonConverter +{ + public override EventOutputConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + EventOutputConversionRateConfig value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize(writer, value.Json, options); } +} - public ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null +[System::Obsolete("deprecated")] +[JsonConverter(typeof(ExternalMarketplaceConverter))] +public enum ExternalMarketplace +{ + Google, + Aws, + Azure, +} + +sealed class ExternalMarketplaceConverter : JsonConverter +{ + public override ExternalMarketplace Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "google" => ExternalMarketplace.Google, + "aws" => ExternalMarketplace.Aws, + "azure" => ExternalMarketplace.Azure, + _ => (ExternalMarketplace)(-1), + }; } - public ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + ExternalMarketplace value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + 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 + ); } +} - public ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ + /// + /// The id of the adjustment to remove on the subscription. + /// + public required string AdjustmentID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment_id"); + } + init { this._rawData.Set("adjustment_id", value); } } - public ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.AdjustmentID; } - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - this.Value = value; - this._element = element; + this.AdjustmentID = adjustmentID; } +} - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) +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. + /// + public string? ExternalPriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + /// + /// The id of the price to remove on the subscription. + /// + public string? PriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price_id"); + } + init { this._rawData.Set("price_id", value); } } - public ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.ExternalPriceID; + _ = this.PriceID; } - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + 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)); + } +} + +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. + /// + 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 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 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 subscription. +/// +[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 ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice(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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - value = this.Value as NewSubscriptionUnitPrice; + 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value - ) + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - value = this.Value as NewSubscriptionTieredPrice; + 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 . + /// 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.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - value = this.Value as NewSubscriptionBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value - ) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as ReplacePricePriceBulkWithFilters; + 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.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as NewSubscriptionPackagePrice; + value = this.Value as NewMaximum; 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.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + public void Switch( + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { - 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; + 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" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// - /// - /// if (instance.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 . + /// Use the TryPick 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public T Match( + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; - return value != null; + return this.Value switch + { + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplaceAdjustmentAdjustment" + ), + }; } - /// - /// Returns true and sets the 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; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + 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); /// - /// 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) + public override void Validate() { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - /// - /// Returns true and sets the 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 - ) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - 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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; - return value != null; + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -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.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +{ + public override ReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as ReplacePricePriceTieredWithProration; - return value != null; + var element = JsonSerializer.Deserialize(ref reader, options); + string? adjustmentType; + try + { + adjustmentType = element.GetProperty("adjustment_type").GetString(); + } + catch + { + adjustmentType = null; + } + + switch (adjustmentType) + { + case "percentage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + 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); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + ReplaceAdjustmentAdjustment value, + JsonSerializerOptions options ) { - value = this.Value as NewSubscriptionUnitWithProrationPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : 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.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the price on the plan to replace in the subscription. /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value - ) + public required string ReplacesPriceID { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_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.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The definition of a new allocation price to create and add to the subscription. /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) + public NewAllocationPrice? AllocationPrice { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", 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.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value - ) + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : 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.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The external price id of the price to add to the subscription. /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - 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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// + /// The new quantity of the price, if the price is a fixed price. /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public double? FixedPriceQuantity { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - 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.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value - ) + [System::Obsolete("deprecated")] + public string? MaximumAmount { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_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.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) + public IReadOnlyDictionary? MetricParameterOverrides { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + 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.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) + [System::Obsolete("deprecated")] + public string? MinimumAmount { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_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.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// New subscription price request body params. /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) + public ReplacePricePrice? Price { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price"); + } + init { this._rawData.Set("price", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the price to add to the subscription. /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) + public string? PriceID { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price_id"); + } + init { this._rawData.Set("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.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) + /// + public override void Validate() { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - return value != null; + _ = 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; } - /// - /// Returns true and sets the 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 - ) + public ReplacePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 + + public ReplacePrice(IReadOnlyDictionary rawData) { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - return value != null; + this._rawData = new(rawData); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePrice(FrozenDictionary rawData) { - value = this.Value as ReplacePricePriceMinimum; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() { - value = this.Value as ReplacePricePricePercent; - return value != null; + this.ReplacesPriceID = replacesPriceID; } +} - /// - /// Returns true and sets the 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) +class ReplacePriceFromRaw : IFromRawJson +{ + /// + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); +} + +/// +/// New subscription price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the 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 - ) + public string ItemID { - switch (this.Value) + get { - 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" - ); + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was 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, + public string Name + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } + } + + public string? BillableMetricID + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } + } + + public bool? BilledInAdvance + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } + } + + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } + } + + public double? ConversionRate + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } + } + + public string? Currency + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } + + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } + } + + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } + } + + public double? FixedPriceQuantity + { + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } + } + + public string? InvoiceGroupingKey + { + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePriceMeteredAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + NewSubscriptionMinimumCompositePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + { + value = this.Value as NewSubscriptionUnitPrice; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + ) + { + value = this.Value as NewSubscriptionTieredPrice; + return value != null; + } + + /// + /// Returns true and sets the 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) + { + value = this.Value as NewSubscriptionBulkPrice; + return value != null; + } + + /// + /// Returns true and sets the 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.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; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `ReplacePricePriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out ReplacePricePriceMatrixWithThresholdDiscounts? value + ) + { + value = this.Value as ReplacePricePriceMatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the 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.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.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out ReplacePricePriceDailyCreditAllowance? value + ) + { + value = this.Value as ReplacePricePriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] out ReplacePricePriceMeteredAllowance? value + ) + { + value = this.Value as ReplacePricePriceMeteredAllowance; + return value != null; + } + + /// + /// Returns true and sets the 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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance 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 matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + 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 ReplacePricePriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(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 ReplacePricePriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case ReplacePricePriceMeteredAllowance value: + meteredAllowance(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) => {...}, + /// (ReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (ReplacePricePriceDailyCreditAllowance value) => {...}, + /// (ReplacePricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func newSubscriptionUnit, System::Func newSubscriptionTiered, System::Func newSubscriptionBulk, System::Func bulkWithFilters, @@ -12963,6 +15326,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, + System::Func matrixWithThresholdDiscounts, System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, @@ -13001,1004 +15365,3153 @@ public T Match( T > newSubscriptionCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput ) { - return this.Value switch + 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 + ), + ReplacePricePriceMatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts( + 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 + ), + ReplacePricePriceDailyCreditAllowance value => dailyCreditAllowance(value), + ReplacePricePriceMeteredAllowance value => meteredAllowance(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( + ReplacePricePriceMatrixWithThresholdDiscounts 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( + ReplacePricePriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceMeteredAllowance 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(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.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 + { + 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, + ReplacePricePriceMatrixWithThresholdDiscounts _ => 14, + ReplacePricePriceTieredWithProration _ => 15, + NewSubscriptionUnitWithProrationPrice _ => 16, + NewSubscriptionGroupedAllocationPrice _ => 17, + NewSubscriptionBulkWithProrationPrice _ => 18, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 19, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 20, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 21, + NewSubscriptionMatrixWithDisplayNamePrice _ => 22, + NewSubscriptionGroupedTieredPackagePrice _ => 23, + NewSubscriptionMaxGroupTieredPackagePrice _ => 24, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 25, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 26, + NewSubscriptionCumulativeGroupedBulkPrice _ => 27, + ReplacePricePriceCumulativeGroupedAllocation _ => 28, + ReplacePricePriceDailyCreditAllowance _ => 29, + ReplacePricePriceMeteredAllowance _ => 30, + NewSubscriptionMinimumCompositePrice _ => 31, + ReplacePricePricePercent _ => 32, + ReplacePricePriceEventOutput _ => 33, + _ => -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 "matrix_with_threshold_discounts": + { + 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + 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 ReplacePricePrice(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePrice? value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +{ + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public 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 ReplacePricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters + ) + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } + } + + /// + public override void Validate() + { + _ = this.PropertyKey; + _ = this.PropertyValue; + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +{ + /// + /// Amount per unit + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// The lower bound for this tier + /// + public string? TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + public override void Validate() + { + _ = this.UnitAmount; + _ = this.TierLowerBound; + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", + ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscounts, + ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscounts : 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); } + } + + /// + /// Configuration for matrix_with_threshold_discounts pricing + /// + public required ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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 ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get { - 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" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice 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(NewSubscriptionBulkPrice 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(ReplacePricePriceBulkWithFilters value) => - new(value); + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => - new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscounts( + ReplacePricePriceMatrixWithThresholdDiscounts replacePricePriceMatrixWithThresholdDiscounts + ) + : base(replacePricePriceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscounts( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => - new(value); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => - new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceMatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter))] +public enum ReplacePricePriceMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom, + _ => (ReplacePricePriceMatrixWithThresholdDiscountsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual => "annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly => "monthly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime => "one_time", + ReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } - public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => - new(value); + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } - public static implicit operator ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } - public static implicit operator ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base(replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} - public static implicit operator ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); + 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( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); + public string? SecondDimensionValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension_value"); + } + init { this._rawData.Set("second_dimension_value", value); } + } - public static implicit operator ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.FirstDimensionValue; + _ = this.UnitAmount; + _ = this.SecondDimensionValue; + } - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewSubscriptionMinimumCompositePrice value) => - new(value); + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// + /// Discount rate applied to spend above the threshold. /// - public override void Validate() + public required string AboveThresholdDiscountPercentage { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); } - 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); + init { this._rawData.Set("above_threshold_discount_percentage", value); } } - public override int GetHashCode() + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage { - return 0; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try + get { - modelType = element.GetProperty("model_type").GetString(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); } - catch + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get { - modelType = null; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); } + init { this._rawData.Set("threshold_amount", value); } + } - switch (modelType) + public string? Description + { + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (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 - } + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", 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 - } + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } - 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 ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + replacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public static ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - 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 - } +class ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} - 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 - } +[JsonConverter(typeof(ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - 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 - } + JsonElement? _element = null; - 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 JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `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 "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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `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_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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } - 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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - 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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - 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 - } + public virtual bool Equals( + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - 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 - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - return new(element); - } - case "percent": +sealed class ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + 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 "event_output": + 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 } @@ -14007,54 +18520,41 @@ JsonSerializerOptions options } default: { - return new ReplacePricePrice(element); + return new ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePrice? value, + ReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : 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); } @@ -14099,6 +18599,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. /// @@ -14158,12 +18673,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14254,6 +18769,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -14292,19 +18820,19 @@ 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") + 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(); @@ -14316,37 +18844,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceBulkWithFilters() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceBulkWithFilters) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14354,172 +18886,127 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this._rawData = new(rawData); + 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), + }; } -#pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(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 + ); } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} - /// -/// Configuration for a single property filter +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// Event property key to filter on + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string PropertyKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData ) { @@ -14528,7 +19015,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -14536,76 +19023,89 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel { /// - /// Amount per unit + /// Inclusive tier starting value /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The lower bound for this tier + /// Amount per unit /// - public string? TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.UnitAmount; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -14614,7 +19114,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -14622,93 +19122,27 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", - ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", - ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", - ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", - ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", - ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14725,7 +19159,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14734,7 +19168,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14743,7 +19177,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -14752,7 +19186,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig(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. /// /// /// @@ -14773,7 +19207,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. /// /// /// @@ -14793,7 +19227,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. /// /// @@ -14804,8 +19238,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14825,7 +19259,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -14834,7 +19268,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. /// /// @@ -14845,8 +19279,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14861,16 +19295,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14889,16 +19323,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -14906,13 +19340,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 ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14941,12 +19388,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14963,12 +19408,10 @@ JsonSerializerOptions 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,14 +19420,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -14994,27 +19437,42 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : 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 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. /// @@ -15054,21 +19512,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 +19571,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15224,6 +19667,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -15263,18 +19719,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15286,37 +19742,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceGroupedWithMinMaxThresholds( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15324,20 +19786,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] -public enum ReplacePricePriceTieredWithProrationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -15347,10 +19809,10 @@ public enum ReplacePricePriceTieredWithProrationCadence Custom, } -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15358,19 +19820,19 @@ 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), + "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, - ReplacePricePriceTieredWithProrationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -15378,12 +19840,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceTieredWithProrationCadence.Annual => "annual", - ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", - ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", - ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", - ReplacePricePriceTieredWithProrationCadence.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)) ), @@ -15394,150 +19856,89 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel -{ - /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig - ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } - - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Inclusive tier starting value + /// The event property used to group before applying thresholds /// - public required string TierLowerBound + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// Amount per unit + /// The maximum amount to charge each group /// - public required string UnitAmount + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -15546,7 +19947,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -15554,8 +19955,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15563,18 +19964,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15591,7 +19994,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15600,7 +20003,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15609,7 +20012,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15618,7 +20021,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 +20042,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 +20062,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 +20073,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15691,7 +20094,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -15700,7 +20103,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 +20114,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15727,16 +20130,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15755,16 +20158,18 @@ 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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } 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( + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -15772,13 +20177,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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15807,12 +20225,10 @@ JsonSerializerOptions 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 +20245,10 @@ JsonSerializerOptions 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 +20257,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -15860,40 +20276,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholds, - ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : 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< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// Configuration for cumulative_grouped_allocation pricing /// - public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -15994,12 +20410,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16090,6 +20506,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +20558,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -16152,39 +20581,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( + public ReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16192,20 +20625,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -16215,10 +20648,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16226,19 +20659,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" => 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, - ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16246,12 +20679,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", + 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)) ), @@ -16262,86 +20695,89 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -16350,7 +20786,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -16358,8 +20794,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16367,20 +20803,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16397,7 +20833,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16406,7 +20842,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16415,7 +20851,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16424,7 +20860,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 +20881,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 +20901,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 +20912,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16497,7 +20933,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -16506,7 +20942,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 +20953,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16533,16 +20969,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16561,18 +20997,18 @@ 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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? 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() { @@ -16580,13 +21016,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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16615,12 +21064,10 @@ JsonSerializerOptions 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 +21084,10 @@ JsonSerializerOptions 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,7 +21096,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -16660,7 +21105,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16670,40 +21115,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceDailyCreditAllowance, + ReplacePricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceDailyCreditAllowance : 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 daily_credit_allowance pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -16804,12 +21249,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16900,6 +21345,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +21397,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -16962,39 +21420,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public ReplacePricePriceCumulativeGroupedAllocation( - ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowance( + ReplacePricePriceDailyCreditAllowance replacePricePriceDailyCreditAllowance ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceDailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceDailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17002,20 +21462,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceDailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceCadenceConverter))] +public enum ReplacePricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -17025,10 +21485,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17036,94 +21496,225 @@ 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" => ReplacePricePriceDailyCreditAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceDailyCreditAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceDailyCreditAllowanceCadence.OneTime, + "custom" => ReplacePricePriceDailyCreditAllowanceCadence.Custom, + _ => (ReplacePricePriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceDailyCreditAllowanceCadence.Annual => "annual", + ReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceDailyCreditAllowanceCadence.Monthly => "monthly", + ReplacePricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceDailyCreditAllowanceCadence.OneTime => "one_time", + ReplacePricePriceDailyCreditAllowanceCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + /// -/// Configuration for cumulative_grouped_allocation pricing +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -17138,20 +21729,21 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -17160,7 +21752,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -17168,8 +21760,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17177,20 +21769,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17207,7 +21799,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17216,7 +21808,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17225,7 +21817,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -17234,7 +21826,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 +21847,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 +21867,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 +21878,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17307,7 +21899,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -17316,7 +21908,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 +21919,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17343,16 +21935,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17371,18 +21963,16 @@ 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 ReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplacePricePriceDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17390,13 +21980,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 ReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17425,12 +22028,10 @@ JsonSerializerOptions 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 +22048,10 @@ JsonSerializerOptions 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,16 +22060,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( - element - ); + return new ReplacePricePriceDailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -17479,21 +22076,24 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceMeteredAllowance, + ReplacePricePriceMeteredAllowanceFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceMeteredAllowance : 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); } } @@ -17512,18 +22112,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -17611,12 +22211,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17707,6 +22307,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -17747,8 +22360,13 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -17764,35 +22382,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowance( + ReplacePricePriceMeteredAllowance replacePricePriceMeteredAllowance + ) + : base(replacePricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17800,19 +22424,19 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceMeteredAllowanceFromRaw : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceCadenceConverter))] +public enum ReplacePricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -17822,10 +22446,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17833,19 +22457,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" => ReplacePricePriceMeteredAllowanceCadence.Annual, + "semi_annual" => ReplacePricePriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => ReplacePricePriceMeteredAllowanceCadence.Monthly, + "quarterly" => ReplacePricePriceMeteredAllowanceCadence.Quarterly, + "one_time" => ReplacePricePriceMeteredAllowanceCadence.OneTime, + "custom" => ReplacePricePriceMeteredAllowanceCadence.Custom, + _ => (ReplacePricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -17853,12 +22477,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", + ReplacePricePriceMeteredAllowanceCadence.Annual => "annual", + ReplacePricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", + ReplacePricePriceMeteredAllowanceCadence.Monthly => "monthly", + ReplacePricePriceMeteredAllowanceCadence.Quarterly => "quarterly", + ReplacePricePriceMeteredAllowanceCadence.OneTime => "one_time", + ReplacePricePriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17869,38 +22493,103 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceMinimumMinimumConfig, - ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig, + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public required string MinimumAmount + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -17909,64 +22598,68 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig replacePricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceMeteredAllowanceMeteredAllowanceConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => ReplacePricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceMeteredAllowanceConversionRateConfigConverter))] +public record class ReplacePricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17983,7 +22676,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +22685,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18001,7 +22694,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -18010,7 +22703,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 +22724,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 +22744,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 +22755,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18083,7 +22776,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -18092,7 +22785,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 +22796,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18119,16 +22812,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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18147,16 +22840,16 @@ 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 ReplacePricePriceMeteredAllowanceConversionRateConfig" ); } 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(ReplacePricePriceMeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18164,13 +22857,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 ReplacePricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18199,12 +22905,10 @@ JsonSerializerOptions 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 +22925,10 @@ JsonSerializerOptions 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 +22937,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceMeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -18479,6 +23181,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +23251,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18545,8 +23261,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 +23391,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 +23482,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 +23503,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 +23523,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 +23534,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18842,7 +23564,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 +23575,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18903,10 +23625,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 +23636,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +23684,10 @@ JsonSerializerOptions 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 +23704,10 @@ JsonSerializerOptions 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 +23960,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +24035,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19300,8 +24045,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 +24206,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 +24299,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 +24320,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 +24340,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 +24351,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19630,7 +24381,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 +24392,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19691,10 +24442,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 +24453,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +24501,10 @@ JsonSerializerOptions 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 +24521,10 @@ JsonSerializerOptions 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..6f36bf7a4 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); } /// @@ -1754,6 +1863,7 @@ public string Currency newFloatingPackageWithAllocation: (x) => x.Currency, newFloatingUnitWithPercent: (x) => x.Currency, newFloatingMatrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, newFloatingTieredWithProration: (x) => x.Currency, newFloatingUnitWithProration: (x) => x.Currency, newFloatingGroupedAllocation: (x) => x.Currency, @@ -1768,7 +1878,8 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1795,6 +1906,7 @@ public string ItemID newFloatingPackageWithAllocation: (x) => x.ItemID, newFloatingUnitWithPercent: (x) => x.ItemID, newFloatingMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, newFloatingTieredWithProration: (x) => x.ItemID, newFloatingUnitWithProration: (x) => x.ItemID, newFloatingGroupedAllocation: (x) => x.ItemID, @@ -1809,7 +1921,8 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1836,6 +1949,7 @@ public string Name newFloatingPackageWithAllocation: (x) => x.Name, newFloatingUnitWithPercent: (x) => x.Name, newFloatingMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, newFloatingTieredWithProration: (x) => x.Name, newFloatingUnitWithProration: (x) => x.Name, newFloatingGroupedAllocation: (x) => x.Name, @@ -1850,7 +1964,8 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1877,6 +1992,7 @@ public string? BillableMetricID newFloatingPackageWithAllocation: (x) => x.BillableMetricID, newFloatingUnitWithPercent: (x) => x.BillableMetricID, newFloatingMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, newFloatingTieredWithProration: (x) => x.BillableMetricID, newFloatingUnitWithProration: (x) => x.BillableMetricID, newFloatingGroupedAllocation: (x) => x.BillableMetricID, @@ -1891,7 +2007,8 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1918,6 +2035,7 @@ public bool? BilledInAdvance newFloatingPackageWithAllocation: (x) => x.BilledInAdvance, newFloatingUnitWithPercent: (x) => x.BilledInAdvance, newFloatingMatrixWithAllocation: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, newFloatingTieredWithProration: (x) => x.BilledInAdvance, newFloatingUnitWithProration: (x) => x.BilledInAdvance, newFloatingGroupedAllocation: (x) => x.BilledInAdvance, @@ -1932,7 +2050,8 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1959,6 +2078,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.BillingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.BillingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, newFloatingTieredWithProration: (x) => x.BillingCycleConfiguration, newFloatingUnitWithProration: (x) => x.BillingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.BillingCycleConfiguration, @@ -1973,7 +2093,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -2000,6 +2121,7 @@ public double? ConversionRate newFloatingPackageWithAllocation: (x) => x.ConversionRate, newFloatingUnitWithPercent: (x) => x.ConversionRate, newFloatingMatrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, newFloatingTieredWithProration: (x) => x.ConversionRate, newFloatingUnitWithProration: (x) => x.ConversionRate, newFloatingGroupedAllocation: (x) => x.ConversionRate, @@ -2014,7 +2136,8 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -2041,6 +2164,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithPercent: (x) => x.DimensionalPriceConfiguration, newFloatingMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, newFloatingTieredWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingUnitWithProration: (x) => x.DimensionalPriceConfiguration, newFloatingGroupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -2055,7 +2179,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -2082,6 +2207,7 @@ public string? ExternalPriceID newFloatingPackageWithAllocation: (x) => x.ExternalPriceID, newFloatingUnitWithPercent: (x) => x.ExternalPriceID, newFloatingMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, newFloatingTieredWithProration: (x) => x.ExternalPriceID, newFloatingUnitWithProration: (x) => x.ExternalPriceID, newFloatingGroupedAllocation: (x) => x.ExternalPriceID, @@ -2096,7 +2222,8 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2123,6 +2250,7 @@ public double? FixedPriceQuantity newFloatingPackageWithAllocation: (x) => x.FixedPriceQuantity, newFloatingUnitWithPercent: (x) => x.FixedPriceQuantity, newFloatingMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, newFloatingTieredWithProration: (x) => x.FixedPriceQuantity, newFloatingUnitWithProration: (x) => x.FixedPriceQuantity, newFloatingGroupedAllocation: (x) => x.FixedPriceQuantity, @@ -2137,7 +2265,8 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2164,6 +2293,7 @@ public string? InvoiceGroupingKey newFloatingPackageWithAllocation: (x) => x.InvoiceGroupingKey, newFloatingUnitWithPercent: (x) => x.InvoiceGroupingKey, newFloatingMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, newFloatingTieredWithProration: (x) => x.InvoiceGroupingKey, newFloatingUnitWithProration: (x) => x.InvoiceGroupingKey, newFloatingGroupedAllocation: (x) => x.InvoiceGroupingKey, @@ -2178,7 +2308,8 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2205,6 +2336,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithPercent: (x) => x.InvoicingCycleConfiguration, newFloatingMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, newFloatingTieredWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingUnitWithProration: (x) => x.InvoicingCycleConfiguration, newFloatingGroupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -2219,7 +2351,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2227,6 +2360,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (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; @@ -2311,6 +2487,12 @@ public PriceModel(NewFloatingMatrixWithAllocationPrice value, JsonElement? eleme this._element = element; } + public PriceModel(PriceModelMatrixWithThresholdDiscounts value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + public PriceModel(NewFloatingTieredWithProrationPrice value, JsonElement? element = null) { this.Value = value; @@ -2401,7 +2583,13 @@ public PriceModel(PriceModelCumulativeGroupedAllocation value, JsonElement? elem this._element = element; } - public PriceModel(PriceModelMinimum value, JsonElement? element = null) + public PriceModel(PriceModelDailyCreditAllowance value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PriceModel(PriceModelMeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2434,7 +2622,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 +2643,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 +2664,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 +2685,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 +2706,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 +2727,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 +2748,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 +2771,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 +2794,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 +2817,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 +2840,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 +2863,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 +2886,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 +2909,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. /// /// /// @@ -2740,11 +2928,34 @@ public bool TryPickNewFloatingMatrixWithAllocation( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `PriceModelMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] out PriceModelMatrixWithThresholdDiscounts? value + ) + { + value = this.Value as PriceModelMatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +2978,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 +3001,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 +3024,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 +3047,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 +3070,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 +3093,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 +3116,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 +3139,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 +3162,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 +3185,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 +3208,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 +3231,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 +3254,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. /// /// /// @@ -3064,22 +3275,45 @@ public bool TryPickCumulativeGroupedAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `PriceModelDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out PriceModelDailyCreditAllowance? value + ) + { + value = this.Value as PriceModelDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with 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.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceModelMinimum` + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `PriceModelMeteredAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out PriceModelMinimum? value) + public bool TryPickMeteredAllowance([NotNullWhen(true)] out PriceModelMeteredAllowance? value) { - value = this.Value as PriceModelMinimum; + value = this.Value as PriceModelMeteredAllowance; return value != null; } @@ -3087,7 +3321,7 @@ public bool TryPickMinimum([NotNullWhen(true)] out PriceModelMinimum? 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. /// /// /// @@ -3110,7 +3344,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 +3365,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 +3385,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 +3396,40 @@ 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) => {...}, + /// (PriceModelMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceModelDailyCreditAllowance value) => {...}, + /// (PriceModelMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3213,6 +3449,7 @@ public void Switch( System::Action newFloatingPackageWithAllocation, System::Action newFloatingUnitWithPercent, System::Action newFloatingMatrixWithAllocation, + System::Action matrixWithThresholdDiscounts, System::Action newFloatingTieredWithProration, System::Action newFloatingUnitWithProration, System::Action newFloatingGroupedAllocation, @@ -3227,7 +3464,8 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -3277,6 +3515,9 @@ public void Switch( case NewFloatingMatrixWithAllocationPrice value: newFloatingMatrixWithAllocation(value); break; + case PriceModelMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case NewFloatingTieredWithProrationPrice value: newFloatingTieredWithProration(value); break; @@ -3319,8 +3560,11 @@ public void Switch( case PriceModelCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceModelMinimum value: - minimum(value); + case PriceModelDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case PriceModelMeteredAllowance value: + meteredAllowance(value); break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); @@ -3340,7 +3584,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 +3595,40 @@ 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) => {...}, + /// (PriceModelMatrixWithThresholdDiscounts 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) => {...}, + /// (PriceModelDailyCreditAllowance value) => {...}, + /// (PriceModelMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3405,6 +3651,7 @@ public T Match( System::Func newFloatingPackageWithAllocation, System::Func newFloatingUnitWithPercent, System::Func newFloatingMatrixWithAllocation, + System::Func matrixWithThresholdDiscounts, System::Func newFloatingTieredWithProration, System::Func newFloatingUnitWithProration, System::Func newFloatingGroupedAllocation, @@ -3431,7 +3678,8 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -3455,6 +3703,7 @@ public T Match( NewFloatingPackageWithAllocationPrice value => newFloatingPackageWithAllocation(value), NewFloatingUnitWithPercentPrice value => newFloatingUnitWithPercent(value), NewFloatingMatrixWithAllocationPrice value => newFloatingMatrixWithAllocation(value), + PriceModelMatrixWithThresholdDiscounts value => matrixWithThresholdDiscounts(value), NewFloatingTieredWithProrationPrice value => newFloatingTieredWithProration(value), NewFloatingUnitWithProrationPrice value => newFloatingUnitWithProration(value), NewFloatingGroupedAllocationPrice value => newFloatingGroupedAllocation(value), @@ -3474,7 +3723,8 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceModelCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceModelMinimum value => minimum(value), + PriceModelDailyCreditAllowance value => dailyCreditAllowance(value), + PriceModelMeteredAllowance value => meteredAllowance(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceModelPercent value => percent(value), PriceModelEventOutput value => eventOutput(value), @@ -3515,6 +3765,9 @@ public static implicit operator PriceModel(NewFloatingPackageWithAllocationPrice public static implicit operator PriceModel(NewFloatingMatrixWithAllocationPrice value) => new(value); + public static implicit operator PriceModel(PriceModelMatrixWithThresholdDiscounts value) => + new(value); + public static implicit operator PriceModel(NewFloatingTieredWithProrationPrice value) => new(value); @@ -3559,7 +3812,9 @@ 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(PriceModelDailyCreditAllowance value) => new(value); + + public static implicit operator PriceModel(PriceModelMeteredAllowance value) => new(value); public static implicit operator PriceModel(NewFloatingMinimumCompositePrice value) => new(value); @@ -3599,6 +3854,7 @@ public override void Validate() (newFloatingPackageWithAllocation) => newFloatingPackageWithAllocation.Validate(), (newFloatingUnitWithPercent) => newFloatingUnitWithPercent.Validate(), (newFloatingMatrixWithAllocation) => newFloatingMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (newFloatingTieredWithProration) => newFloatingTieredWithProration.Validate(), (newFloatingUnitWithProration) => newFloatingUnitWithProration.Validate(), (newFloatingGroupedAllocation) => newFloatingGroupedAllocation.Validate(), @@ -3617,17 +3873,18 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +3892,52 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + 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, + PriceModelMatrixWithThresholdDiscounts _ => 14, + NewFloatingTieredWithProrationPrice _ => 15, + NewFloatingUnitWithProrationPrice _ => 16, + NewFloatingGroupedAllocationPrice _ => 17, + NewFloatingBulkWithProrationPrice _ => 18, + NewFloatingGroupedWithProratedMinimumPrice _ => 19, + NewFloatingGroupedWithMeteredMinimumPrice _ => 20, + PriceModelGroupedWithMinMaxThresholds _ => 21, + NewFloatingMatrixWithDisplayNamePrice _ => 22, + NewFloatingGroupedTieredPackagePrice _ => 23, + NewFloatingMaxGroupTieredPackagePrice _ => 24, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 25, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 26, + NewFloatingCumulativeGroupedBulkPrice _ => 27, + PriceModelCumulativeGroupedAllocation _ => 28, + PriceModelDailyCreditAllowance _ => 29, + PriceModelMeteredAllowance _ => 30, + NewFloatingMinimumCompositePrice _ => 31, + PriceModelPercent _ => 32, + PriceModelEventOutput _ => 33, + _ => -1, + }; + } } sealed class PriceModelConverter : JsonConverter @@ -3669,12 +3971,10 @@ JsonSerializerOptions 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 +3991,10 @@ JsonSerializerOptions 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 +4011,10 @@ JsonSerializerOptions 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 +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 } @@ -3757,12 +4051,10 @@ JsonSerializerOptions 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 +4071,10 @@ JsonSerializerOptions 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 +4092,10 @@ JsonSerializerOptions 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 +4112,10 @@ JsonSerializerOptions 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 +4133,10 @@ JsonSerializerOptions 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 +4153,10 @@ JsonSerializerOptions 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 +4174,10 @@ JsonSerializerOptions 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 +4195,10 @@ JsonSerializerOptions 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 +4215,10 @@ JsonSerializerOptions 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 +4236,31 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -3983,12 +4278,10 @@ JsonSerializerOptions 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 +4299,10 @@ JsonSerializerOptions 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 +4320,10 @@ JsonSerializerOptions 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 +4341,10 @@ JsonSerializerOptions 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 +4362,10 @@ JsonSerializerOptions 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 +4383,10 @@ JsonSerializerOptions 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 +4404,10 @@ JsonSerializerOptions 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 +4425,10 @@ JsonSerializerOptions 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 +4446,10 @@ JsonSerializerOptions 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 +4467,10 @@ JsonSerializerOptions 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 +4488,10 @@ JsonSerializerOptions 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 +4509,10 @@ JsonSerializerOptions 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 +4530,10 @@ JsonSerializerOptions 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 +4551,50 @@ JsonSerializerOptions 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 "daily_credit_allowance": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": { 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 } @@ -4326,12 +4611,10 @@ JsonSerializerOptions 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 +4631,10 @@ JsonSerializerOptions 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 +4651,10 @@ JsonSerializerOptions 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 +4906,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4967,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4683,8 +4976,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 +5082,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 +5169,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 +5258,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 +5413,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 +5434,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 +5454,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 +5465,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5190,7 +5495,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 +5506,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5251,10 +5556,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 +5567,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5615,10 @@ JsonSerializerOptions 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 +5635,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5350,22 +5664,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceModelGroupedWithMinMaxThresholds, - PriceModelGroupedWithMinMaxThresholdsFromRaw + PriceModelMatrixWithThresholdDiscounts, + PriceModelMatrixWithThresholdDiscountsFromRaw >) )] -public sealed record class PriceModelGroupedWithMinMaxThresholds : JsonModel +public sealed record class PriceModelMatrixWithThresholdDiscounts : 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); } @@ -5385,31 +5699,31 @@ public required string Currency } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// The id of the item the price will be associated with. /// - public required PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for matrix_with_threshold_discounts pricing /// - public required string ItemID + public required PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// @@ -5497,12 +5811,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public PriceModelMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5580,11 +5894,1923 @@ 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("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + 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.LicenseTypeID; + _ = this.Metadata; + } + + public PriceModelMatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMatrixWithThresholdDiscounts( + PriceModelMatrixWithThresholdDiscounts priceModelMatrixWithThresholdDiscounts + ) + : base(priceModelMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 + + public PriceModelMatrixWithThresholdDiscounts(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelMatrixWithThresholdDiscounts(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelMatrixWithThresholdDiscountsFromRaw + : IFromRawJson +{ + /// + public PriceModelMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceModelMatrixWithThresholdDiscounts.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceModelMatrixWithThresholdDiscountsCadenceConverter))] +public enum PriceModelMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceModelMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override PriceModelMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceModelMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => PriceModelMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => PriceModelMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => PriceModelMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => PriceModelMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => PriceModelMatrixWithThresholdDiscountsCadence.Custom, + _ => (PriceModelMatrixWithThresholdDiscountsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceModelMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceModelMatrixWithThresholdDiscountsCadence.Annual => "annual", + PriceModelMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", + PriceModelMatrixWithThresholdDiscountsCadence.Monthly => "monthly", + PriceModelMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", + PriceModelMatrixWithThresholdDiscountsCadence.OneTime => "one_time", + PriceModelMatrixWithThresholdDiscountsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base(priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig) { } +#pragma warning restore CS8618 + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base(priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue) + { } +#pragma warning restore CS8618 + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + priceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 + + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceModelMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(PriceModelMatrixWithThresholdDiscountsConversionRateConfigConverter))] +public record class PriceModelMatrixWithThresholdDiscountsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceModelMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelMatrixWithThresholdDiscountsConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceModelMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceModelMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceModelMatrixWithThresholdDiscountsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceModelMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override PriceModelMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceModelMatrixWithThresholdDiscountsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceModelMatrixWithThresholdDiscountsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceModelGroupedWithMinMaxThresholds, + PriceModelGroupedWithMinMaxThresholdsFromRaw + >) +)] +public sealed record class PriceModelGroupedWithMinMaxThresholds : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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 PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + } + + 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) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelGroupedWithMinMaxThresholds(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson +{ + /// + public PriceModelGroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceModelGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceModelGroupedWithMinMaxThresholdsCadenceConverter))] +public enum PriceModelGroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceModelGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override PriceModelGroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => PriceModelGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => PriceModelGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => PriceModelGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => PriceModelGroupedWithMinMaxThresholdsCadence.Custom, + _ => (PriceModelGroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceModelGroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceModelGroupedWithMinMaxThresholdsCadence.Annual => "annual", + PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + PriceModelGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + PriceModelGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + PriceModelGroupedWithMinMaxThresholdsCadence.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< + PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + ) + : base(priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson +{ + /// + public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class PriceModelGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } + + public static implicit operator PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter +{ + public override PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceModelGroupedWithMinMaxThresholdsConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceModelCumulativeGroupedAllocation, + PriceModelCumulativeGroupedAllocationFromRaw + >) +)] +public sealed record class PriceModelCumulativeGroupedAllocation : 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 PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", 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); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public PriceModelCumulativeGroupedAllocationConversionRateConfig? 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { get { @@ -5604,13 +7830,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -5627,36 +7853,40 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceModelGroupedWithMinMaxThresholds() + public PriceModelCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public PriceModelGroupedWithMinMaxThresholds( - PriceModelGroupedWithMinMaxThresholds priceModelGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelCumulativeGroupedAllocation( + PriceModelCumulativeGroupedAllocation priceModelCumulativeGroupedAllocation ) - : base(priceModelGroupedWithMinMaxThresholds) { } + : base(priceModelCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public PriceModelGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public PriceModelCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelGroupedWithMinMaxThresholds(FrozenDictionary rawData) + PriceModelCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceModelGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static PriceModelCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5664,20 +7894,20 @@ IReadOnlyDictionary rawData } } -class PriceModelGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class PriceModelCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public PriceModelGroupedWithMinMaxThresholds FromRawUnchecked( + public PriceModelCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceModelGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => PriceModelCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceModelGroupedWithMinMaxThresholdsCadenceConverter))] -public enum PriceModelGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(PriceModelCumulativeGroupedAllocationCadenceConverter))] +public enum PriceModelCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -5687,10 +7917,10 @@ public enum PriceModelGroupedWithMinMaxThresholdsCadence Custom, } -sealed class PriceModelGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PriceModelCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override PriceModelGroupedWithMinMaxThresholdsCadence Read( + public override PriceModelCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5698,19 +7928,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PriceModelGroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => PriceModelGroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => PriceModelGroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => PriceModelGroupedWithMinMaxThresholdsCadence.Custom, - _ => (PriceModelGroupedWithMinMaxThresholdsCadence)(-1), + "annual" => PriceModelCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => PriceModelCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => PriceModelCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => PriceModelCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => PriceModelCumulativeGroupedAllocationCadence.OneTime, + "custom" => PriceModelCumulativeGroupedAllocationCadence.Custom, + _ => (PriceModelCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceModelGroupedWithMinMaxThresholdsCadence value, + PriceModelCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -5718,12 +7948,12 @@ JsonSerializerOptions options writer, value switch { - PriceModelGroupedWithMinMaxThresholdsCadence.Annual => "annual", - PriceModelGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - PriceModelGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - PriceModelGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - PriceModelGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - PriceModelGroupedWithMinMaxThresholdsCadence.Custom => "custom", + PriceModelCumulativeGroupedAllocationCadence.Annual => "annual", + PriceModelCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + PriceModelCumulativeGroupedAllocationCadence.Monthly => "monthly", + PriceModelCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + PriceModelCumulativeGroupedAllocationCadence.OneTime => "one_time", + PriceModelCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5734,86 +7964,89 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -5822,7 +8055,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -5830,8 +8063,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5839,20 +8072,20 @@ IReadOnlyDictionary rawData } } -class PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class PriceModelGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceModelCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PriceModelCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5869,7 +8102,7 @@ public JsonElement Json } } - public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceModelCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5878,7 +8111,7 @@ public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + public PriceModelCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5887,7 +8120,7 @@ public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PriceModelCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -5896,7 +8129,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 +8150,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 +8170,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 +8181,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5969,7 +8202,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -5978,7 +8211,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 +8222,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6005,16 +8238,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceModelCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceModelGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PriceModelCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6033,16 +8266,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" ); } 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(PriceModelCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6050,13 +8283,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 PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PriceModelCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PriceModelCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6085,12 +8331,10 @@ JsonSerializerOptions 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 +8351,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6121,14 +8363,14 @@ JsonSerializerOptions options } default: { - return new PriceModelGroupedWithMinMaxThresholdsConversionRateConfig(element); + return new PriceModelCumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceModelGroupedWithMinMaxThresholdsConversionRateConfig value, + PriceModelCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6138,53 +8380,53 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceModelCumulativeGroupedAllocation, - PriceModelCumulativeGroupedAllocationFromRaw + PriceModelDailyCreditAllowance, + PriceModelDailyCreditAllowanceFromRaw >) )] -public sealed record class PriceModelCumulativeGroupedAllocation : JsonModel +public sealed record class PriceModelDailyCreditAllowance : 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 + /// An ISO 4217 currency string for which this price is billed in. /// - public required PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("currency", value); } } /// - /// An ISO 4217 currency string for which this price is billed in. + /// Configuration for daily_credit_allowance pricing /// - public required string Currency + public required PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -6285,12 +8527,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceModelCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public PriceModelDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6367,6 +8609,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6392,13 +8647,13 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -6415,36 +8670,40 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceModelCumulativeGroupedAllocation() + public PriceModelDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public PriceModelCumulativeGroupedAllocation( - PriceModelCumulativeGroupedAllocation priceModelCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelDailyCreditAllowance( + PriceModelDailyCreditAllowance priceModelDailyCreditAllowance ) - : base(priceModelCumulativeGroupedAllocation) { } + : base(priceModelDailyCreditAllowance) { } +#pragma warning restore CS8618 - public PriceModelCumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public PriceModelDailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelCumulativeGroupedAllocation(FrozenDictionary rawData) + PriceModelDailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceModelCumulativeGroupedAllocation FromRawUnchecked( + /// + public static PriceModelDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6452,20 +8711,19 @@ IReadOnlyDictionary rawData } } -class PriceModelCumulativeGroupedAllocationFromRaw - : IFromRawJson +class PriceModelDailyCreditAllowanceFromRaw : IFromRawJson { /// - public PriceModelCumulativeGroupedAllocation FromRawUnchecked( + public PriceModelDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceModelCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => PriceModelDailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceModelCumulativeGroupedAllocationCadenceConverter))] -public enum PriceModelCumulativeGroupedAllocationCadence +[JsonConverter(typeof(PriceModelDailyCreditAllowanceCadenceConverter))] +public enum PriceModelDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -6475,10 +8733,10 @@ public enum PriceModelCumulativeGroupedAllocationCadence Custom, } -sealed class PriceModelCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PriceModelDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override PriceModelCumulativeGroupedAllocationCadence Read( + public override PriceModelDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6486,19 +8744,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PriceModelCumulativeGroupedAllocationCadence.Annual, - "semi_annual" => PriceModelCumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => PriceModelCumulativeGroupedAllocationCadence.Monthly, - "quarterly" => PriceModelCumulativeGroupedAllocationCadence.Quarterly, - "one_time" => PriceModelCumulativeGroupedAllocationCadence.OneTime, - "custom" => PriceModelCumulativeGroupedAllocationCadence.Custom, - _ => (PriceModelCumulativeGroupedAllocationCadence)(-1), + "annual" => PriceModelDailyCreditAllowanceCadence.Annual, + "semi_annual" => PriceModelDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => PriceModelDailyCreditAllowanceCadence.Monthly, + "quarterly" => PriceModelDailyCreditAllowanceCadence.Quarterly, + "one_time" => PriceModelDailyCreditAllowanceCadence.OneTime, + "custom" => PriceModelDailyCreditAllowanceCadence.Custom, + _ => (PriceModelDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceModelCumulativeGroupedAllocationCadence value, + PriceModelDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -6506,12 +8764,12 @@ JsonSerializerOptions options writer, value switch { - PriceModelCumulativeGroupedAllocationCadence.Annual => "annual", - PriceModelCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - PriceModelCumulativeGroupedAllocationCadence.Monthly => "monthly", - PriceModelCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - PriceModelCumulativeGroupedAllocationCadence.OneTime => "one_time", - PriceModelCumulativeGroupedAllocationCadence.Custom => "custom", + PriceModelDailyCreditAllowanceCadence.Annual => "annual", + PriceModelDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", + PriceModelDailyCreditAllowanceCadence.Monthly => "monthly", + PriceModelDailyCreditAllowanceCadence.Quarterly => "quarterly", + PriceModelDailyCreditAllowanceCadence.OneTime => "one_time", + PriceModelDailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6522,58 +8780,188 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig, + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw >) )] -public sealed record class PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - : JsonModel +public sealed record class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig : JsonModel { /// - /// The overall allocation across all groups + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string CumulativeAllocation + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("daily_allowance", value); } } /// - /// The allocation per individual group + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public required string GroupAllocation + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("default_unit_amount"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("default_unit_amount", value); } } /// - /// The event property used to group usage before applying allocations + /// One or two event property values to evaluate matrix groups by /// - public required string GroupingKey + public required IReadOnlyList Dimensions { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig( + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig priceModelDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base(priceModelDailyCreditAllowanceDailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 + + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked(rawData); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + : JsonModel +{ + /// + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. + /// + public required IReadOnlyList DimensionValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -6588,20 +8976,21 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) - : base(priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(priceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 - public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -6610,7 +8999,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -6618,8 +9007,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6627,20 +9016,20 @@ IReadOnlyDictionary rawData } } -class PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(PriceModelCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class PriceModelCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceModelDailyCreditAllowanceConversionRateConfigConverter))] +public record class PriceModelDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6657,7 +9046,7 @@ public JsonElement Json } } - public PriceModelCumulativeGroupedAllocationConversionRateConfig( + public PriceModelDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6666,7 +9055,7 @@ public PriceModelCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public PriceModelCumulativeGroupedAllocationConversionRateConfig( + public PriceModelDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6675,7 +9064,7 @@ public PriceModelCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public PriceModelCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PriceModelDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6684,7 +9073,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 +9094,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 +9114,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 +9125,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6757,7 +9146,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" ); } } @@ -6766,7 +9155,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 +9166,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6793,16 +9182,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceModelCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceModelDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceModelCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PriceModelDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6821,16 +9210,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" ); } 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(PriceModelDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6838,13 +9227,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); -sealed class PriceModelCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceModelDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceModelCumulativeGroupedAllocationConversionRateConfig? Read( + public override PriceModelDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6873,12 +9275,10 @@ JsonSerializerOptions 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 +9295,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6909,14 +9307,14 @@ JsonSerializerOptions options } default: { - return new PriceModelCumulativeGroupedAllocationConversionRateConfig(element); + return new PriceModelDailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceModelCumulativeGroupedAllocationConversionRateConfig value, + PriceModelDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6924,20 +9322,22 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceModelMinimum : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PriceModelMeteredAllowance : 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); } } @@ -6969,16 +9369,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required PriceModelMinimumMinimumConfig MinimumConfig + public required PriceModelMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -7066,12 +9468,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceModelMinimumConversionRateConfig? ConversionRateConfig + public PriceModelMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7148,6 +9550,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7175,8 +9590,13 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -7191,34 +9611,38 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceModelMinimum() + public PriceModelMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public PriceModelMinimum(PriceModelMinimum priceModelMinimum) - : base(priceModelMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMeteredAllowance(PriceModelMeteredAllowance priceModelMeteredAllowance) + : base(priceModelMeteredAllowance) { } +#pragma warning restore CS8618 - public PriceModelMinimum(IReadOnlyDictionary rawData) + public PriceModelMeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelMinimum(FrozenDictionary rawData) + PriceModelMeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceModelMinimum FromRawUnchecked( + /// + public static PriceModelMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7226,18 +9650,19 @@ IReadOnlyDictionary rawData } } -class PriceModelMinimumFromRaw : IFromRawJson +class PriceModelMeteredAllowanceFromRaw : IFromRawJson { /// - public PriceModelMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceModelMinimum.FromRawUnchecked(rawData); + public PriceModelMeteredAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceModelMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceModelMinimumCadenceConverter))] -public enum PriceModelMinimumCadence +[JsonConverter(typeof(PriceModelMeteredAllowanceCadenceConverter))] +public enum PriceModelMeteredAllowanceCadence { Annual, SemiAnnual, @@ -7247,9 +9672,10 @@ public enum PriceModelMinimumCadence Custom, } -sealed class PriceModelMinimumCadenceConverter : JsonConverter +sealed class PriceModelMeteredAllowanceCadenceConverter + : JsonConverter { - public override PriceModelMinimumCadence Read( + public override PriceModelMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7257,19 +9683,19 @@ 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), + "annual" => PriceModelMeteredAllowanceCadence.Annual, + "semi_annual" => PriceModelMeteredAllowanceCadence.SemiAnnual, + "monthly" => PriceModelMeteredAllowanceCadence.Monthly, + "quarterly" => PriceModelMeteredAllowanceCadence.Quarterly, + "one_time" => PriceModelMeteredAllowanceCadence.OneTime, + "custom" => PriceModelMeteredAllowanceCadence.Custom, + _ => (PriceModelMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceModelMinimumCadence value, + PriceModelMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -7277,12 +9703,12 @@ JsonSerializerOptions options writer, value switch { - PriceModelMinimumCadence.Annual => "annual", - PriceModelMinimumCadence.SemiAnnual => "semi_annual", - PriceModelMinimumCadence.Monthly => "monthly", - PriceModelMinimumCadence.Quarterly => "quarterly", - PriceModelMinimumCadence.OneTime => "one_time", - PriceModelMinimumCadence.Custom => "custom", + PriceModelMeteredAllowanceCadence.Annual => "annual", + PriceModelMeteredAllowanceCadence.SemiAnnual => "semi_annual", + PriceModelMeteredAllowanceCadence.Monthly => "monthly", + PriceModelMeteredAllowanceCadence.Quarterly => "quarterly", + PriceModelMeteredAllowanceCadence.OneTime => "one_time", + PriceModelMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7293,38 +9719,103 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceModelMinimumMinimumConfig, - PriceModelMinimumMinimumConfigFromRaw + PriceModelMeteredAllowanceMeteredAllowanceConfig, + PriceModelMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class PriceModelMinimumMinimumConfig : JsonModel +public sealed record class PriceModelMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public required string MinimumAmount + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -7333,63 +9824,66 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public PriceModelMinimumMinimumConfig() { } + public PriceModelMeteredAllowanceMeteredAllowanceConfig() { } - public PriceModelMinimumMinimumConfig( - PriceModelMinimumMinimumConfig priceModelMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelMeteredAllowanceMeteredAllowanceConfig( + PriceModelMeteredAllowanceMeteredAllowanceConfig priceModelMeteredAllowanceMeteredAllowanceConfig ) - : base(priceModelMinimumMinimumConfig) { } + : base(priceModelMeteredAllowanceMeteredAllowanceConfig) { } +#pragma warning restore CS8618 - public PriceModelMinimumMinimumConfig(IReadOnlyDictionary rawData) + public PriceModelMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceModelMinimumMinimumConfig(FrozenDictionary rawData) + PriceModelMeteredAllowanceMeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceModelMinimumMinimumConfig FromRawUnchecked( + /// + public static PriceModelMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PriceModelMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class PriceModelMinimumMinimumConfigFromRaw : IFromRawJson +class PriceModelMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public PriceModelMinimumMinimumConfig FromRawUnchecked( + public PriceModelMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceModelMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => PriceModelMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceModelMinimumConversionRateConfigConverter))] -public record class PriceModelMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PriceModelMeteredAllowanceConversionRateConfigConverter))] +public record class PriceModelMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7406,7 +9900,7 @@ public JsonElement Json } } - public PriceModelMinimumConversionRateConfig( + public PriceModelMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7415,7 +9909,7 @@ public PriceModelMinimumConversionRateConfig( this._element = element; } - public PriceModelMinimumConversionRateConfig( + public PriceModelMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7424,7 +9918,7 @@ public PriceModelMinimumConversionRateConfig( this._element = element; } - public PriceModelMinimumConversionRateConfig(JsonElement element) + public PriceModelMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -7433,7 +9927,7 @@ public PriceModelMinimumConversionRateConfig(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. /// /// /// @@ -7454,7 +9948,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. /// /// /// @@ -7474,7 +9968,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. /// /// @@ -7485,8 +9979,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7506,7 +10000,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" + "Data did not match any variant of PriceModelMeteredAllowanceConversionRateConfig" ); } } @@ -7515,7 +10009,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. /// /// @@ -7526,8 +10020,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7542,16 +10036,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" + "Data did not match any variant of PriceModelMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceModelMinimumConversionRateConfig( + public static implicit operator PriceModelMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceModelMinimumConversionRateConfig( + public static implicit operator PriceModelMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7570,16 +10064,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" + "Data did not match any variant of PriceModelMeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelMeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7587,13 +10081,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 PriceModelMinimumConversionRateConfigConverter - : JsonConverter +sealed class PriceModelMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceModelMinimumConversionRateConfig? Read( + public override PriceModelMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7622,12 +10129,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7644,12 +10149,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7658,14 +10161,14 @@ JsonSerializerOptions options } default: { - return new PriceModelMinimumConversionRateConfig(element); + return new PriceModelMeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceModelMinimumConversionRateConfig value, + PriceModelMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -7897,6 +10400,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10456,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7948,8 +10465,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 +10593,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 +10683,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 +10704,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 +10724,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 +10735,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8242,7 +10765,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 +10776,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8303,10 +10826,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 +10837,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10885,10 @@ JsonSerializerOptions 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 +10905,10 @@ JsonSerializerOptions 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 +11158,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +11219,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -8682,8 +11228,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 +11388,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 +11479,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 +11500,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 +11520,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 +11531,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9009,7 +11561,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 +11572,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9070,10 +11622,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 +11633,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +11681,10 @@ JsonSerializerOptions 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 +11701,10 @@ JsonSerializerOptions 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 +11813,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 +11914,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 +11933,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 +11957,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 +11968,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9434,7 +11998,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 +12009,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9499,10 +12063,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 +12074,20 @@ public override int GetHashCode() } 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 +12118,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 +12244,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 +12265,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 +12286,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 +12307,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 +12328,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 +12348,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 +12359,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 +12404,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 +12415,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 +12492,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 +12503,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 +12554,10 @@ JsonSerializerOptions 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 +12574,10 @@ JsonSerializerOptions 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 +12594,10 @@ JsonSerializerOptions 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 +12611,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 +12628,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 +12706,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 +12725,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 +12749,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 +12760,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10204,7 +12790,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 +12801,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10269,10 +12855,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 +12866,20 @@ public override int GetHashCode() } 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 +12910,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 +13031,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 +13111,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 +13201,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 +13220,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 +13244,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 +13255,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10655,7 +13283,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 +13294,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10711,10 +13339,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 +13350,20 @@ public override int GetHashCode() } 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 +13393,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 +13459,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 +13543,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 +13562,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 +13586,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 +13597,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10980,7 +13627,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 +13638,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11039,10 +13686,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 +13697,20 @@ public override int GetHashCode() } 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 +13740,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 +13825,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 +13911,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 +13930,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 +13954,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 +13965,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11329,7 +13995,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 +14006,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11392,10 +14058,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 +14069,20 @@ public override int GetHashCode() } 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 +14112,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 +14181,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 +14200,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 +14224,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 +14235,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11583,7 +14265,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 +14276,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11646,10 +14328,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 +14339,20 @@ public override int GetHashCode() } 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 +14382,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..072dc3597 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 @@ -1626,6 +1709,7 @@ public string ItemID newSubscriptionPackageWithAllocation: (x) => x.ItemID, newSubscriptionUnitWithPercent: (x) => x.ItemID, newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + matrixWithThresholdDiscounts: (x) => x.ItemID, tieredWithProration: (x) => x.ItemID, newSubscriptionUnitWithProration: (x) => x.ItemID, newSubscriptionGroupedAllocation: (x) => x.ItemID, @@ -1640,7 +1724,8 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1667,6 +1752,7 @@ public string Name newSubscriptionPackageWithAllocation: (x) => x.Name, newSubscriptionUnitWithPercent: (x) => x.Name, newSubscriptionMatrixWithAllocation: (x) => x.Name, + matrixWithThresholdDiscounts: (x) => x.Name, tieredWithProration: (x) => x.Name, newSubscriptionUnitWithProration: (x) => x.Name, newSubscriptionGroupedAllocation: (x) => x.Name, @@ -1681,7 +1767,8 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1708,6 +1795,7 @@ public string? BillableMetricID newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + matrixWithThresholdDiscounts: (x) => x.BillableMetricID, tieredWithProration: (x) => x.BillableMetricID, newSubscriptionUnitWithProration: (x) => x.BillableMetricID, newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, @@ -1722,7 +1810,8 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1749,6 +1838,7 @@ public bool? BilledInAdvance newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + matrixWithThresholdDiscounts: (x) => x.BilledInAdvance, tieredWithProration: (x) => x.BilledInAdvance, newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, @@ -1763,7 +1853,8 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1790,6 +1881,7 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.BillingCycleConfiguration, tieredWithProration: (x) => x.BillingCycleConfiguration, newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, @@ -1804,7 +1896,8 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1831,6 +1924,7 @@ public double? ConversionRate newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, newSubscriptionUnitWithPercent: (x) => x.ConversionRate, newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + matrixWithThresholdDiscounts: (x) => x.ConversionRate, tieredWithProration: (x) => x.ConversionRate, newSubscriptionUnitWithProration: (x) => x.ConversionRate, newSubscriptionGroupedAllocation: (x) => x.ConversionRate, @@ -1845,7 +1939,8 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1872,6 +1967,7 @@ public string? Currency newSubscriptionPackageWithAllocation: (x) => x.Currency, newSubscriptionUnitWithPercent: (x) => x.Currency, newSubscriptionMatrixWithAllocation: (x) => x.Currency, + matrixWithThresholdDiscounts: (x) => x.Currency, tieredWithProration: (x) => x.Currency, newSubscriptionUnitWithProration: (x) => x.Currency, newSubscriptionGroupedAllocation: (x) => x.Currency, @@ -1886,7 +1982,8 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1913,6 +2010,7 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + matrixWithThresholdDiscounts: (x) => x.DimensionalPriceConfiguration, tieredWithProration: (x) => x.DimensionalPriceConfiguration, newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, @@ -1929,7 +2027,8 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1956,6 +2055,7 @@ public string? ExternalPriceID newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + matrixWithThresholdDiscounts: (x) => x.ExternalPriceID, tieredWithProration: (x) => x.ExternalPriceID, newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, @@ -1970,7 +2070,8 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -1997,6 +2098,7 @@ public double? FixedPriceQuantity newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (x) => x.FixedPriceQuantity, tieredWithProration: (x) => x.FixedPriceQuantity, newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, @@ -2011,7 +2113,8 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2038,6 +2141,7 @@ public string? InvoiceGroupingKey newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (x) => x.InvoiceGroupingKey, tieredWithProration: (x) => x.InvoiceGroupingKey, newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, @@ -2052,7 +2156,8 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2079,6 +2184,7 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (x) => x.InvoicingCycleConfiguration, tieredWithProration: (x) => x.InvoicingCycleConfiguration, newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, @@ -2094,7 +2200,8 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2102,6 +2209,49 @@ 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -2121,6 +2271,7 @@ public string? ReferenceID newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, newSubscriptionUnitWithPercent: (x) => x.ReferenceID, newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + matrixWithThresholdDiscounts: (x) => x.ReferenceID, tieredWithProration: (x) => x.ReferenceID, newSubscriptionUnitWithProration: (x) => x.ReferenceID, newSubscriptionGroupedAllocation: (x) => x.ReferenceID, @@ -2135,7 +2286,8 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2269,6 +2421,15 @@ public SubscriptionSchedulePlanChangeParamsAddPricePrice( this._element = element; } + public SubscriptionSchedulePlanChangeParamsAddPricePrice( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + public SubscriptionSchedulePlanChangeParamsAddPricePrice( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value, JsonElement? element = null @@ -2396,7 +2557,16 @@ public SubscriptionSchedulePlanChangeParamsAddPricePrice( } public SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePrice( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value, JsonElement? element = null ) { @@ -2440,7 +2610,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 +2631,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 +2654,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 +2675,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 +2699,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 +2722,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 +2745,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 +2768,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 +2791,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 +2814,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 +2837,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 +2860,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 +2883,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 +2906,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. /// /// /// @@ -2755,11 +2925,37 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( return value != null; } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts? value + ) + { + value = + this.Value + as SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts; + return value != null; + } + /// /// Returns true and sets the out parameter if the instance was constructed with 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 +2979,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 +3002,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 +3025,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 +3048,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 +3071,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 +3094,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 +3120,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 +3143,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 +3166,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 +3189,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 +3212,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 +3235,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 +3258,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. /// /// /// @@ -3086,24 +3282,49 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance? value + ) + { + value = this.Value as SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with 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.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum` + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum? value + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance? value ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum; + value = this.Value as SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance; return value != null; } @@ -3111,7 +3332,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. /// /// /// @@ -3134,7 +3355,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 +3378,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 +3400,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 +3411,40 @@ 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3241,6 +3464,7 @@ public void Switch( System::Action newSubscriptionPackageWithAllocation, System::Action newSubscriptionUnitWithPercent, System::Action newSubscriptionMatrixWithAllocation, + System::Action matrixWithThresholdDiscounts, System::Action tieredWithProration, System::Action newSubscriptionUnitWithProration, System::Action newSubscriptionGroupedAllocation, @@ -3255,7 +3479,8 @@ public void Switch( System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newSubscriptionMinimumComposite, System::Action percent, System::Action eventOutput @@ -3305,6 +3530,9 @@ public void Switch( case NewSubscriptionMatrixWithAllocationPrice value: newSubscriptionMatrixWithAllocation(value); break; + case SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; case SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value: tieredWithProration(value); break; @@ -3347,8 +3575,11 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value: - minimum(value); + case SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value: + meteredAllowance(value); break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); @@ -3370,7 +3601,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 +3612,40 @@ 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3447,6 +3680,10 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, + System::Func< + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts, + T + > matrixWithThresholdDiscounts, System::Func< SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration, T @@ -3494,7 +3731,14 @@ public T Match( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, + System::Func< + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance, + T + > dailyCreditAllowance, + System::Func< + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance, + T + > meteredAllowance, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3524,6 +3768,8 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( value ), + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts value => + matrixWithThresholdDiscounts(value), SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value => tieredWithProration(value), NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), @@ -3553,7 +3799,10 @@ public T Match( ), SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value => minimum(value), + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value => + dailyCreditAllowance(value), + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value => + meteredAllowance(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), SubscriptionSchedulePlanChangeParamsAddPricePricePercent value => percent(value), SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value => eventOutput( @@ -3621,6 +3870,10 @@ public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePric NewSubscriptionMatrixWithAllocationPrice value ) => new(value); + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts value + ) => new(value); + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value ) => new(value); @@ -3678,7 +3931,11 @@ SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation val ) => new(value); public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value ) => new(value); public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( @@ -3728,6 +3985,7 @@ public override void Validate() newSubscriptionPackageWithAllocation.Validate(), (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.Validate(), (tieredWithProration) => tieredWithProration.Validate(), (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), @@ -3749,17 +4007,18 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.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 +4026,52 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + 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, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts _ => 14, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration _ => 15, + NewSubscriptionUnitWithProrationPrice _ => 16, + NewSubscriptionGroupedAllocationPrice _ => 17, + NewSubscriptionBulkWithProrationPrice _ => 18, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 19, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 20, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds _ => 21, + NewSubscriptionMatrixWithDisplayNamePrice _ => 22, + NewSubscriptionGroupedTieredPackagePrice _ => 23, + NewSubscriptionMaxGroupTieredPackagePrice _ => 24, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 25, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 26, + NewSubscriptionCumulativeGroupedBulkPrice _ => 27, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation _ => 28, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance _ => 29, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance _ => 30, + NewSubscriptionMinimumCompositePrice _ => 31, + SubscriptionSchedulePlanChangeParamsAddPricePricePercent _ => 32, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput _ => 33, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceConverter @@ -3802,12 +4106,10 @@ JsonSerializerOptions 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 +4126,10 @@ JsonSerializerOptions 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 +4146,10 @@ JsonSerializerOptions 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 +4167,10 @@ JsonSerializerOptions 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 +4187,10 @@ JsonSerializerOptions 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 +4207,10 @@ JsonSerializerOptions 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 +4228,10 @@ JsonSerializerOptions 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 +4249,10 @@ JsonSerializerOptions 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 +4270,10 @@ JsonSerializerOptions 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 +4291,10 @@ JsonSerializerOptions 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 +4312,10 @@ JsonSerializerOptions 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 +4333,10 @@ JsonSerializerOptions 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 +4354,10 @@ JsonSerializerOptions 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 +4375,31 @@ JsonSerializerOptions 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_threshold_discounts": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -4120,12 +4417,10 @@ JsonSerializerOptions 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 +4438,10 @@ JsonSerializerOptions 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 +4459,10 @@ JsonSerializerOptions 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 +4480,10 @@ JsonSerializerOptions 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 +4501,10 @@ JsonSerializerOptions 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 +4522,10 @@ JsonSerializerOptions 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 +4543,10 @@ JsonSerializerOptions 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 +4564,10 @@ JsonSerializerOptions 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 +4585,10 @@ JsonSerializerOptions 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 +4606,10 @@ JsonSerializerOptions 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 +4627,10 @@ JsonSerializerOptions 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 +4648,10 @@ JsonSerializerOptions 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 +4669,10 @@ JsonSerializerOptions 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 +4690,52 @@ JsonSerializerOptions 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": { try { var deserialized = - JsonSerializer.Deserialize( + 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 +4753,10 @@ JsonSerializerOptions 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 +4774,10 @@ JsonSerializerOptions 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 +4795,10 @@ JsonSerializerOptions 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 +5061,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5136,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4850,10 +5146,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 +5259,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 +5355,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 +5451,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 +5632,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 +5653,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 +5673,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 +5684,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5406,7 +5714,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 +5725,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5469,10 +5777,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 +5788,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5836,10 @@ JsonSerializerOptions 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 +5856,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5570,11 +5887,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts : JsonModel { /// @@ -5582,7 +5899,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTier /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence > Cadence { get @@ -5591,7 +5908,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence > >("cadence"); } @@ -5612,44 +5929,44 @@ public required string ItemID } /// - /// The pricing model type + /// Configuration for matrix_with_threshold_discounts pricing /// - public JsonElement ModelType + public required SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("matrix_with_threshold_discounts_config", value); } } /// - /// The name of the price. + /// The pricing model type /// - public required string Name + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("model_type", value); } } /// - /// Configuration for tiered_with_proration pricing + /// The name of the price. /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("name", value); } } /// @@ -5711,12 +6028,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5807,6 +6124,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5847,17 +6177,17 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -5869,32 +6199,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration - ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts + ) + : base(subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts( FrozenDictionary rawData ) { @@ -5902,8 +6236,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5911,14 +6245,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscounts.FromRawUnchecked( rawData ); } @@ -5927,9 +6261,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence { Annual, SemiAnnual, @@ -5939,10 +6273,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5951,24 +6285,27 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence value, JsonSerializerOptions options ) { @@ -5976,17 +6313,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -5998,58 +6335,129 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for matrix_with_threshold_discounts pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Unit price used for usage that does not match any defined matrix cell. /// - public required IReadOnlyList Tiers + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + ImmutableArray + >("matrix_values"); } init { this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); } } /// public override void Validate() { - foreach (var item in this.Tiers) + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) { item.Validate(); } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig() + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig ) : base( - subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( IReadOnlyDictionary rawData ) { @@ -6058,7 +6466,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( FrozenDictionary rawData ) { @@ -6066,92 +6474,220 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData ) - : this() { - this.Tiers = tiers; + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( rawData ); } -/// -/// Configuration for a single tiered with proration tier -/// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup : JsonModel { /// - /// Inclusive tier starting value + /// Discount rate applied to spend above the threshold. /// - public required string TierLowerBound + public required string AboveThresholdDiscountPercentage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("above_threshold_discount_percentage", value); } } /// - /// Amount per unit + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. /// - public required string UnitAmount + public required string BelowThresholdDiscountPercentage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("below_threshold_discount_percentage", value); } + } + + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", value); } + } + + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", value); } + } + + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } } /// public override void Validate() { - _ = this.TierLowerBound; - _ = this.UnitAmount; + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier() + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup ) : base( - subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + subscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( IReadOnlyDictionary rawData ) { @@ -6160,7 +6696,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( FrozenDictionary rawData ) { @@ -6168,8 +6704,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6177,22 +6713,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6210,7 +6746,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6219,7 +6755,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6228,7 +6764,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( JsonElement element ) { @@ -6239,7 +6775,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 +6796,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 +6816,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 +6827,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6312,7 +6848,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig" ); } } @@ -6321,7 +6857,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 +6868,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6348,16 +6884,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6376,18 +6912,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6395,13 +6931,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6430,12 +6979,10 @@ JsonSerializerOptions 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 +6999,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6466,7 +7011,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig( element ); } @@ -6475,7 +7020,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6485,11 +7030,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration : JsonModel { /// @@ -6497,7 +7042,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceGrou /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > Cadence { get @@ -6506,28 +7051,13 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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. /// @@ -6567,6 +7097,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig 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. /// @@ -6626,12 +7171,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6722,6 +7267,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,18 +7319,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(); @@ -6784,32 +7342,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( 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] - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( FrozenDictionary rawData ) { @@ -6817,8 +7379,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6826,14 +7388,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration.FromRawUnchecked( rawData ); } @@ -6842,9 +7404,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -6854,10 +7416,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxTh Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6866,27 +7428,24 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom, - _ => - (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence)( - -1 - ), + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -6894,17 +7453,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -6916,89 +7475,61 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig : 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 + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string MinimumCharge + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("minimum_charge", value); } - } - - /// - /// The base price charged per group - /// - public required string PerUnitRate - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) : base( - subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData ) { @@ -7007,7 +7538,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -7015,32 +7546,137 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( rawData ); } +/// +/// Configuration for a single tiered with proration tier +/// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig - : ModelBase +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + : 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 SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + ) + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig + : ModelBase { public object? Value { get; } = null; @@ -7057,7 +7693,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7066,7 +7702,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresho this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7075,7 +7711,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresho this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -7086,7 +7722,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 +7743,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 +7763,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 +7774,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7159,7 +7795,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" ); } } @@ -7168,7 +7804,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 +7815,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7195,16 +7831,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7223,18 +7859,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7242,13 +7878,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 SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7277,12 +7926,10 @@ JsonSerializerOptions 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 +7946,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7313,7 +7958,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig( element ); } @@ -7322,7 +7967,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7332,11 +7977,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -7344,7 +7989,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumu /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -7353,7 +7998,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } @@ -7361,18 +8006,18 @@ public required ApiEnum< } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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); } } /// @@ -7473,12 +8118,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7569,6 +8214,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7608,12 +8266,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") ) ) { @@ -7631,32 +8289,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( 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] - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( FrozenDictionary rawData ) { @@ -7664,8 +8326,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7673,14 +8335,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -7689,9 +8351,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -7701,10 +8363,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAl Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7713,19 +8375,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom, _ => - (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence)( + (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence)( -1 ), }; @@ -7733,7 +8395,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -7741,17 +8403,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom => + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -7763,89 +8425,92 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : 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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( - subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -7854,7 +8519,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -7862,8 +8527,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7871,22 +8536,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7904,7 +8569,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7913,7 +8578,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7922,7 +8587,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -7933,7 +8598,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 +8619,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 +8639,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 +8650,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8006,7 +8671,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -8015,7 +8680,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 +8691,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8042,16 +8707,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8070,18 +8735,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8089,13 +8754,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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8124,12 +8802,10 @@ JsonSerializerOptions 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 +8822,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8160,7 +8834,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -8169,7 +8843,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -8179,56 +8853,60 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + > >("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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig 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 SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig 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); } } /// @@ -8316,12 +8994,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8412,6 +9090,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -8451,9 +9142,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"); } @@ -8469,32 +9165,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum subscriptionSchedulePlanChangeParamsAddPricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( FrozenDictionary rawData ) { @@ -8502,8 +9202,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8511,20 +9211,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -8534,10 +9239,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8545,21 +9250,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -8567,16 +9279,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8587,66 +9301,92 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : 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 SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig) { } + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -8655,7 +9395,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -8663,40 +9403,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw - : IFromRawJson -{ +class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson +{ /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8714,7 +9445,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8723,7 +9454,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8732,7 +9463,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -8743,7 +9474,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 +9495,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 +9515,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 +9526,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8816,7 +9547,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -8825,7 +9556,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 +9567,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8852,16 +9583,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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8880,18 +9611,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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8899,13 +9630,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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8934,12 +9678,10 @@ JsonSerializerOptions 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 +9698,10 @@ JsonSerializerOptions 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 +9710,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -8979,7 +9719,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -8989,30 +9729,49 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercent, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for daily_credit_allowance pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); + } + init { this._rawData.Set("daily_credit_allowance_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -9052,21 +9811,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 +9870,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9222,6 +9966,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10018,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -9279,32 +10041,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( - SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( FrozenDictionary rawData ) { @@ -9312,8 +10078,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9321,20 +10087,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -9344,10 +10115,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9355,21 +10126,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -9377,16 +10152,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9397,44 +10174,124 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required double Percent + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() + { } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -9443,7 +10300,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( FrozenDictionary rawData ) { @@ -9451,74 +10308,170 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked( rawData ); } +/// +/// Per-dimension credit price for the daily credit allowance model. +/// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + >) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig - : ModelBase +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + /// + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. + /// + public required IReadOnlyList DimensionValues { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) ); } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Credits charged per unit of usage matching the specified dimension_values + /// + 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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { + /// + public override void Validate() + { + _ = this.DimensionValues; + _ = this.UnitAmount; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { this.Value = value; this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( JsonElement element ) { @@ -9529,7 +10482,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 +10503,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 +10523,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 +10534,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9602,7 +10555,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -9611,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. /// /// @@ -9622,8 +10575,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9638,16 +10591,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9666,18 +10619,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9685,13 +10638,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9720,12 +10686,10 @@ JsonSerializerOptions 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 +10706,10 @@ JsonSerializerOptions 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 +10718,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( element ); } @@ -9765,7 +10727,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9775,56 +10737,60 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence + > >("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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig 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. + /// Configuration for metered_allowance pricing /// - public required string ItemID + public required SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -9912,12 +10878,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -10008,6 +10974,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -10047,12 +11026,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("event_output") + JsonSerializer.SerializeToElement("metered_allowance") ) ) { @@ -10070,32 +11049,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( FrozenDictionary rawData ) { @@ -10103,8 +11086,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10112,22 +11095,23 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -10137,10 +11121,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10148,23 +11132,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -10172,17 +11158,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -10194,75 +11180,141 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The key in the event data to extract the unit rate from. + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public required string UnitRatingKey + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._rawData.GetNotNullClass("allowance_grouping_value"); } - init { this._rawData.Set("unit_rating_key", value); } + init { this._rawData.Set("allowance_grouping_value", 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 grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. /// - public string? DefaultUnitRate + public required string ConsumptionGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return this._rawData.GetNotNullClass("consumption_grouping_value"); } - init { this._rawData.Set("default_unit_rate", value); } + init { this._rawData.Set("consumption_grouping_value", 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. + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. /// - public string? GroupingKey + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullClass("grouping_key"); } init { this._rawData.Set("grouping_key", value); } } + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); + } + } + + /// + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + /// + public string? ConsumptionDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); + } + } + /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig() + { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -10271,7 +11323,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( FrozenDictionary rawData ) { @@ -10279,40 +11331,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - string unitRatingKey - ) - : this() - { - this.UnitRatingKey = unitRatingKey; - } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -10330,7 +11373,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -10339,7 +11382,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -10348,7 +11391,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -10359,7 +11402,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. /// /// /// @@ -10380,7 +11423,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. /// /// /// @@ -10400,7 +11443,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. /// /// @@ -10411,8 +11454,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10432,7 +11475,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -10441,7 +11484,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,8 +11495,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10468,16 +11511,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -10496,18 +11539,18 @@ 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 SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10515,13 +11558,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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10550,12 +11606,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10572,12 +11626,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10586,7 +11638,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( element ); } @@ -10595,7 +11647,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -10603,275 +11655,341 @@ JsonSerializerOptions options } } -/// -/// Reset billing periods to be aligned with the plan change's effective date or start -/// of the month. Defaults to `unchanged` which keeps subscription's existing billing -/// cycle alignment. -/// -[JsonConverter(typeof(BillingCycleAlignmentConverter))] -public enum BillingCycleAlignment -{ - Unchanged, - PlanChangeDate, - StartOfMonth, -} - -sealed class BillingCycleAlignmentConverter : JsonConverter -{ - public override BillingCycleAlignment Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "unchanged" => BillingCycleAlignment.Unchanged, - "plan_change_date" => BillingCycleAlignment.PlanChangeDate, - "start_of_month" => BillingCycleAlignment.StartOfMonth, - _ => (BillingCycleAlignment)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - BillingCycleAlignment value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - BillingCycleAlignment.Unchanged => "unchanged", - BillingCycleAlignment.PlanChangeDate => "plan_change_date", - BillingCycleAlignment.StartOfMonth => "start_of_month", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsRemoveAdjustment, - SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePricePercent, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel { /// - /// The id of the adjustment to remove on the subscription. + /// The cadence to bill for this price on. /// - public required string AdjustmentID + public required ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + > Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("cadence", value); } } - /// - public override void Validate() + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - _ = this.AdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - IReadOnlyDictionary rawData - ) + /// + /// The pricing model type + /// + public JsonElement ModelType { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - FrozenDictionary 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 restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// Configuration for percent pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig PercentConfig { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "percent_config" + ); + } + init { this._rawData.Set("percent_config", value); } } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) - : this() + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } -} - -class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsRemovePrice, - SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. /// - public string? ExternalPriceID + public bool? BilledInAdvance { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNullableStruct("billed_in_advance"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("billed_in_advance", value); } } /// - /// The id of the price to remove on the subscription. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public string? PriceID + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - /// - public override void Validate() + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { - _ = this.ExternalPriceID; - _ = this.PriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } } - public SubscriptionSchedulePlanChangeParamsRemovePrice() { } - - public SubscriptionSchedulePlanChangeParamsRemovePrice( - SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice - ) - : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } - - public SubscriptionSchedulePlanChangeParamsRemovePrice( - IReadOnlyDictionary rawData - ) + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } } -} -class SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsRemovePrice.FromRawUnchecked(rawData); -} + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplaceAdjustment, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplaceAdjustment : JsonModel -{ /// - /// The definition of a new adjustment to create and add to the subscription. + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// The ID of the license type to associate with this price. /// - public required string ReplacesAdjustmentID + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableClass("license_type_id"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + { + this.ModelType = JsonSerializer.SerializeToElement("percent"); + } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent ) - : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent( FrozenDictionary rawData ) { @@ -10879,8 +11997,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10888,223 +12006,259 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplaceAdjustment.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the subscription. +/// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] +public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence { - public object? Value { get; } = null; - - JsonElement? _element = null; + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public JsonElement Json +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, + "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, + "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), + }; } - 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 override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => + "semi_annual", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => + "monthly", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => + "quarterly", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => + "one_time", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} - public bool? IsInvoiceLevel +/// +/// Configuration for percent pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + : JsonModel +{ + /// + /// What percent of the component subtotals to charge + /// + public required double Percent { 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.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Percent; } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + ) + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + FrozenDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value, - JsonElement? element = null + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value, - JsonElement? element = null - ) + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) + : this() { - this.Value = value; - this._element = element; + this.Percent = percent; } +} - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - this._element = element; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - /// - /// Returns true and sets the 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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { - value = this.Value as NewPercentageDiscount; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { - value = this.Value as NewUsageDiscount; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + JsonElement element + ) { - value = this.Value as NewAmountDiscount; - return value != null; + 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. /// /// @@ -11115,43 +12269,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); + case SharedUnitConversionRateConfig value: + unit(value); break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); + case SharedTieredConversionRateConfig value: + tiered(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } } @@ -11160,7 +12299,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. /// /// @@ -11171,54 +12310,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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ), }; } - 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 + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + SharedTieredConversionRateConfig value ) => new(value); /// @@ -11236,24 +12354,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } - 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( - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? 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() { @@ -11261,129 +12373,78 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; + string? conversionRateType; try { - adjustmentType = element.GetProperty("adjustment_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - adjustmentType = null; + conversionRateType = null; } - switch (adjustmentType) + switch (conversionRateType) { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "usage_discount": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); 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": + 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) - { - // 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) + catch (JsonException) { // ignore } @@ -11392,14 +12453,16 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -11409,847 +12472,583 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePrice, - SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel { /// - /// The id of the price on the plan to replace in the subscription. + /// The cadence to bill for this price on. /// - public required string ReplacesPriceID + public required ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } - init { this._rawData.Set("replaces_price_id", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The definition of a new allocation price to create and add to the subscription. + /// Configuration for event_output pricing /// - public NewAllocationPrice? AllocationPrice + public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); + return this._rawData.GetNotNullClass( + "event_output_config" + ); } - init { this._rawData.Set("allocation_price", value); } + init { this._rawData.Set("event_output_config", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. + /// The id of the item the price will be associated with. /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("item_id"); } + init { this._rawData.Set("item_id", value); } } /// - /// The external price id of the price to add to the subscription. + /// The pricing model type /// - public string? ExternalPriceID + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The new quantity of the price, if the price is a fixed price. + /// The name of the price. /// - public double? FixedPriceQuantity + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("fixed_price_quantity", value); } + init { this._rawData.Set("name", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + public string? BillableMetricID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); + return this._rawData.GetNullableClass("billable_metric_id"); } - init { this._rawData.Set("maximum_amount", value); } + init { this._rawData.Set("billable_metric_id", value); } } /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public bool? BilledInAdvance { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); + return this._rawData.GetNullableStruct("billed_in_advance"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("billed_in_advance", value); } } /// - /// New subscription price request body params. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The id of the price to add to the subscription. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public string? PriceID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("conversion_rate", value); } } - /// - public override void Validate() + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + init { this._rawData.Set("conversion_rate_config", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - - public SubscriptionSchedulePlanChangeParamsReplacePrice( - SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice - ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } - - public SubscriptionSchedulePlanChangeParamsReplacePrice( - IReadOnlyDictionary rawData - ) + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary 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 restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// An alias for the price. + /// + public string? ExternalPriceID { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } -} - -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - JsonElement? _element = null; - - public JsonElement Json + /// + /// 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 ItemID + /// + /// Within each 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( - 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._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string Name + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public string? BillableMetricID + /// + /// User-specified key/value pairs for the resource. Individual keys can be 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( - 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._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public bool? BilledInAdvance + /// + /// 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( - 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._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + public override void Validate() { - get + this.Cadence.Validate(); + this.EventOutputConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { - 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 - ); + throw new OrbInvalidDataException("Invalid value given for constant"); } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public double? ConversionRate + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - 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.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public string? Currency +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + ) + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + IReadOnlyDictionary rawData + ) { - 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._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + FrozenDictionary rawData + ) { - 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._rawData = new(rawData); } +#pragma warning restore CS8618 - public string? ExternalPriceID + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - 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 - ); - } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public double? FixedPriceQuantity +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - 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 - ); - } + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), + }; } - public string? InvoiceGroupingKey + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, + JsonSerializerOptions options + ) { - 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 - ); - } + 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 + ); } +} - public NewBillingCycleConfiguration? InvoicingCycleConfiguration +/// +/// 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 { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); } + init { this._rawData.Set("unit_rating_key", value); } } - public string? ReferenceID + /// + /// 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 { - 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); } + init { this._rawData.Set("default_unit_rate", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value, - JsonElement? element = null - ) + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig ) - { - this.Value = value; - this._element = element; - } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + FrozenDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value, - JsonElement? element = null + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value, - JsonElement? element = null + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + string unitRatingKey ) + : this() { - this.Value = value; - this._element = element; + this.UnitRatingKey = unitRatingKey; } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null - ) +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { - this.Value = value; - this._element = element; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value, + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, JsonElement? element = null ) { @@ -12257,8 +13056,8 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePrice( this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, JsonElement? element = null ) { @@ -12266,2286 +13065,6665 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePrice( this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + JsonElement element ) { - this.Value = value; this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice 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.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - this.Value = value; - this._element = element; + value = this.Value as SharedUnitConversionRateConfig; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice 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.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - this.Value = value; - this._element = element; + value = this.Value as SharedTieredConversionRateConfig; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, - JsonElement? element = null + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered ) { - this.Value = value; - this._element = element; + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + ); + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered ) { - this.Value = value; - this._element = element; + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + ), + }; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() { - this.Value = value; - this._element = element; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - this.Value = value; - this._element = element; + return 0; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - this.Value = value; - this._element = element; + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + element + ); + } + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize(writer, value.Json, options); } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null +/// +/// Reset billing periods to be aligned with the plan change's effective date or start +/// of the month. Defaults to `unchanged` which keeps subscription's existing billing +/// cycle alignment. +/// +[JsonConverter(typeof(BillingCycleAlignmentConverter))] +public enum BillingCycleAlignment +{ + Unchanged, + PlanChangeDate, + StartOfMonth, +} + +sealed class BillingCycleAlignmentConverter : JsonConverter +{ + public override BillingCycleAlignment Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unchanged" => BillingCycleAlignment.Unchanged, + "plan_change_date" => BillingCycleAlignment.PlanChangeDate, + "start_of_month" => BillingCycleAlignment.StartOfMonth, + _ => (BillingCycleAlignment)(-1), + }; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + BillingCycleAlignment value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + 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 + ); } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsRemoveAdjustment, + SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel +{ + /// + /// The id of the adjustment to remove on the subscription. + /// + public required string AdjustmentID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment_id"); + } + init { this._rawData.Set("adjustment_id", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.AdjustmentID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment ) - { - this.Value = value; - this._element = element; - } + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + FrozenDictionary rawData ) { - 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; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, - JsonElement? element = null + /// + public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, - JsonElement? element = null - ) + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) + : this() { - this.Value = value; - this._element = element; + this.AdjustmentID = adjustmentID; } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) - { - this._element = element; - } +class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsRemovePrice, + SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : 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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The external price id of the price to remove on the subscription. /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public string? ExternalPriceID { - value = this.Value as NewSubscriptionUnitPrice; - 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the price to remove on the subscription. /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value - ) + public string? PriceID { - value = this.Value as NewSubscriptionTieredPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price_id"); + } + init { this._rawData.Set("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.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + /// + public override void Validate() { - value = this.Value as NewSubscriptionBulkPrice; - return value != null; + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// Returns true and sets the 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 + public SubscriptionSchedulePlanChangeParamsRemovePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemovePrice( + SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + ) + : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + IReadOnlyDictionary rawData ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; - return value != null; + this._rawData = new(rawData); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) { - value = this.Value as NewSubscriptionPackagePrice; - return value != null; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + /// + public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + IReadOnlyDictionary rawData ) { - value = this.Value as NewSubscriptionMatrixPrice; - return value != null; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The definition of a new adjustment to create and add to the subscription. /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value - ) + public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "adjustment" + ); + } + init { this._rawData.Set("adjustment", 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.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the adjustment on the plan to replace in the subscription. /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + IReadOnlyDictionary rawData ) { - value = this.Value as NewSubscriptionTieredPackagePrice; - return value != null; + 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 + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsReplaceAdjustment.FromRawUnchecked(rawData); +} + +/// +/// The definition of a new adjustment to create and add to the subscription. +/// +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter))] +public record class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment : 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value - ) + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + 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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value - ) + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + 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 . + /// 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.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value - ) + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + 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.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as NewSubscriptionUnitWithPercentPrice; + value = this.Value as NewMaximum; 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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value + public void Switch( + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value - ) - { - value = - this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; - return value != null; + switch (this.Value) + { + case NewPercentageDiscount value: + newPercentageDiscount(value); + break; + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// - /// - /// if (instance.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 . + /// Use the TryPick 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.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value + public T Match( + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; + return this.Value switch + { + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + ), + }; } - /// - /// Returns true and sets the 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; - } + 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); /// - /// 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.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value - ) + public override void Validate() { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - /// - /// Returns true and sets the 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 - ) + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - 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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -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.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value +sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; + var element = JsonSerializer.Deserialize(ref reader, options); + string? adjustmentType; + try + { + adjustmentType = element.GetProperty("adjustment_type").GetString(); + } + catch + { + adjustmentType = null; + } + + switch (adjustmentType) + { + case "percentage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, + JsonSerializerOptions options ) { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePrice, + SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : 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.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the price on the plan to replace in the subscription. /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) + public required string ReplacesPriceID { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_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.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The definition of a new allocation price to create and add to the subscription. /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) + public NewAllocationPrice? AllocationPrice { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : 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.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The external price id of the price to add to the subscription. /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - 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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// + /// The new quantity of the price, if the price is a fixed price. /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value - ) + public double? FixedPriceQuantity { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value - ) + [System::Obsolete("deprecated")] + public string? MaximumAmount { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_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.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value - ) + public IReadOnlyDictionary? MetricParameterOverrides { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + 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.TryPickPercent(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. /// - public bool TryPickPercent( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value - ) + [System::Obsolete("deprecated")] + public string? MinimumAmount { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_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.TryPickEventOutput(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// + /// New subscription price request body params. /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value - ) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "price" + ); + } + init { this._rawData.Set("price", 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( - /// (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) => {...} - /// ); - /// - /// + /// The id of the price to add to the subscription. /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, - System::Action newSubscriptionBulk, - System::Action bulkWithFilters, - System::Action newSubscriptionPackage, - System::Action newSubscriptionMatrix, - System::Action newSubscriptionThresholdTotalAmount, - System::Action newSubscriptionTieredPackage, - System::Action newSubscriptionTieredWithMinimum, - System::Action newSubscriptionGroupedTiered, - System::Action newSubscriptionTieredPackageWithMinimum, - System::Action newSubscriptionPackageWithAllocation, - System::Action newSubscriptionUnitWithPercent, - System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newSubscriptionUnitWithProration, - System::Action newSubscriptionGroupedAllocation, - System::Action newSubscriptionBulkWithProration, - System::Action newSubscriptionGroupedWithProratedMinimum, - System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newSubscriptionMatrixWithDisplayName, - System::Action newSubscriptionGroupedTieredPackage, - System::Action newSubscriptionMaxGroupTieredPackage, - System::Action newSubscriptionScalableMatrixWithUnitPricing, - System::Action newSubscriptionScalableMatrixWithTieredPricing, - System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput - ) + public string? PriceID { - switch (this.Value) + get { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: - percent(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price_id"); } + init { this._rawData.Set("price_id", 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( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, - T - > eventOutput - ) + /// + public override void Validate() { - return this.Value switch + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( - value - ), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ), - }; + item.Validate(); + } + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; + _ = this.MinimumAmount; + this.Price?.Validate(); + _ = this.PriceID; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice( + SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice + ) + : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePrice( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value - ) => new(value); + /// + public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } +} - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value - ) => new(value); +class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); +} - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value - ) => new(value); +/// +/// New subscription price request body params. +/// +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] +public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase +{ + public object? Value { get; } = null; - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice" + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) + public string ItemID { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } } - public override int GetHashCode() + public string Name { - return 0; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public string? BillableMetricID { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try + get { - modelType = element.GetProperty("model_type").GetString(); + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); } - catch + } + + public bool? BilledInAdvance + { + get { - modelType = null; + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); } + } - switch (modelType) + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } + } - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.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 double? ConversionRate + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } + } - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public string? Currency + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } - return new(element); - } - case "bulk_with_filters": - { - try - { + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } + } + + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } + } + + public double? FixedPriceQuantity + { + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } + } + + public string? InvoiceGroupingKey + { + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + + 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, + matrixWithThresholdDiscounts: (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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null + ) + { + 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance 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; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + { + value = this.Value as NewSubscriptionUnitPrice; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + ) + { + value = this.Value as NewSubscriptionTieredPrice; + return value != null; + } + + /// + /// Returns true and sets the 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) + { + value = this.Value as NewSubscriptionBulkPrice; + return value != null; + } + + /// + /// Returns true and sets the 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 + ) + { + 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; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMatrixWithThresholdDiscounts(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMatrixWithThresholdDiscounts( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts? value + ) + { + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value + ) + { + value = + this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnitWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithProration( + [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value + ) + { + value = this.Value as NewSubscriptionUnitWithProrationPrice; + return value != null; + } + + /// + /// Returns true and sets the 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 `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value + ) + { + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// 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 `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value + ) + { + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance? value + ) + { + value = + this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance? value + ) + { + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance; + return value != null; + } + + /// + /// Returns true and sets the 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 `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent( + [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value + ) + { + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value + ) + { + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action newSubscriptionUnit, + System::Action newSubscriptionTiered, + System::Action newSubscriptionBulk, + System::Action bulkWithFilters, + System::Action newSubscriptionPackage, + System::Action newSubscriptionMatrix, + System::Action newSubscriptionThresholdTotalAmount, + System::Action newSubscriptionTieredPackage, + System::Action newSubscriptionTieredWithMinimum, + System::Action newSubscriptionGroupedTiered, + System::Action newSubscriptionTieredPackageWithMinimum, + System::Action newSubscriptionPackageWithAllocation, + System::Action newSubscriptionUnitWithPercent, + System::Action newSubscriptionMatrixWithAllocation, + System::Action matrixWithThresholdDiscounts, + 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 dailyCreditAllowance, + System::Action meteredAllowance, + System::Action newSubscriptionMinimumComposite, + System::Action percent, + System::Action eventOutput + ) + { + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts value: + matrixWithThresholdDiscounts(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value: + dailyCreditAllowance(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance value: + meteredAllowance(value); + break; + case NewSubscriptionMinimumCompositePrice value: + newSubscriptionMinimumComposite(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: + percent(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts 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) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func newSubscriptionUnit, + System::Func newSubscriptionTiered, + System::Func newSubscriptionBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, + T + > bulkWithFilters, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts, + T + > matrixWithThresholdDiscounts, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + T + > tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + T + > groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + T + > cumulativeGroupedAllocation, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance, + T + > dailyCreditAllowance, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance, + T + > meteredAllowance, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, + T + > eventOutput + ) + { + return this.Value switch + { + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => + bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts value => + matrixWithThresholdDiscounts(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => + tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => + groupedWithMinMaxThresholds(value), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => + cumulativeGroupedAllocation(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value => + dailyCreditAllowance(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance value => + meteredAllowance(value), + NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( + value + ), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ), + }; + } + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } + this.Switch( + (newSubscriptionUnit) => newSubscriptionUnit.Validate(), + (newSubscriptionTiered) => newSubscriptionTiered.Validate(), + (newSubscriptionBulk) => newSubscriptionBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newSubscriptionPackage) => newSubscriptionPackage.Validate(), + (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), + (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), + (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), + (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), + (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), + (newSubscriptionTieredPackageWithMinimum) => + newSubscriptionTieredPackageWithMinimum.Validate(), + (newSubscriptionPackageWithAllocation) => + newSubscriptionPackageWithAllocation.Validate(), + (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), + (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (matrixWithThresholdDiscounts) => matrixWithThresholdDiscounts.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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + 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, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts _ => + 14, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration _ => 15, + NewSubscriptionUnitWithProrationPrice _ => 16, + NewSubscriptionGroupedAllocationPrice _ => 17, + NewSubscriptionBulkWithProrationPrice _ => 18, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 19, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 20, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds _ => + 21, + NewSubscriptionMatrixWithDisplayNamePrice _ => 22, + NewSubscriptionGroupedTieredPackagePrice _ => 23, + NewSubscriptionMaxGroupTieredPackagePrice _ => 24, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 25, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 26, + NewSubscriptionCumulativeGroupedBulkPrice _ => 27, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation _ => + 28, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance _ => 29, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance _ => 30, + NewSubscriptionMinimumCompositePrice _ => 31, + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent _ => 32, + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput _ => 33, + _ => -1, + }; + } +} + +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } + + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + 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 "matrix_with_threshold_discounts": + { + 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( + 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "metered_allowance": + { + 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) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) + { + // 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); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + ) + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + IReadOnlyDictionary rawData + ) + { + 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() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) { } +#pragma warning restore CS8618 + + 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() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) { } +#pragma warning restore CS8618 + + 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() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual => + "semi_annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly => + "monthly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly => + "quarterly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime => + "one_time", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + JsonElement element + ) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +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; + } + + 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); - } - 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); + } + default: + { + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// The id of the item the price will 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 matrix_with_threshold_discounts pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig MatrixWithThresholdDiscountsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_threshold_discounts_config" + ); + } + init { this._rawData.Set("matrix_with_threshold_discounts_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 SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + this.MatrixWithThresholdDiscountsConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("matrix_with_threshold_discounts") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts() + { + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts + ) + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts) + { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_threshold_discounts"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscounts.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence)( + -1 + ), + }; + } + + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.SemiAnnual => + "semi_annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Monthly => + "monthly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Quarterly => + "quarterly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.OneTime => + "one_time", + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for matrix_with_threshold_discounts pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + : JsonModel +{ + /// + /// Unit price used for usage that does not match any defined matrix cell. + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// First matrix dimension key. + /// + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Per-cell unit prices. + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Optional second matrix dimension key. + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } + } + + public IReadOnlyList? ThresholdDiscountGroups + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray + >("threshold_discount_groups"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set?>( + "threshold_discount_groups", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.DefaultUnitAmount; + _ = this.FirstDimension; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + _ = this.SecondDimension; + foreach (var item in this.ThresholdDiscountGroups ?? []) + { + item.Validate(); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfig.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + : 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 UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", 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.UnitAmount; + _ = this.SecondDimensionValue; + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + : JsonModel +{ + /// + /// Discount rate applied to spend above the threshold. + /// + public required string AboveThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("above_threshold_discount_percentage"); + } + init { this._rawData.Set("above_threshold_discount_percentage", value); } + } + + /// + /// Discount rate applied to spend at or below the threshold. Set to 0 for no + /// baseline discount. + /// + public required string BelowThresholdDiscountPercentage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("below_threshold_discount_percentage"); + } + init { this._rawData.Set("below_threshold_discount_percentage", 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 - } + /// + /// Semicolon-separated list of matrix cell coordinates targeted by this group. + /// Each coordinate is `first,second` when the matrix has two dimensions, or just + /// `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + /// + public required string CellCoordinates + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cell_coordinates"); + } + init { this._rawData.Set("cell_coordinates", 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 - } + public required string ThresholdAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("threshold_amount"); + } + init { this._rawData.Set("threshold_amount", 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 - } + public string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", 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 - } + /// + public override void Validate() + { + _ = this.AboveThresholdDiscountPercentage; + _ = this.BelowThresholdDiscountPercentage; + _ = this.CellCoordinates; + _ = this.ThresholdAmount; + _ = this.Description; + } - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup() + { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup + ) { } +#pragma warning restore CS8618 - 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 - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - 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 - } +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroupFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsMatrixWithThresholdDiscountsConfigThresholdDiscountGroup.FromRawUnchecked( + rawData + ); +} - 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 - } +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter) +)] +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; - 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 - } + JsonElement? _element = null; - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + JsonElement element + ) + { + this._element = element; + } - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + } - 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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ), + }; + } - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - 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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - 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 - } + public override int GetHashCode() + { + return 0; + } - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - 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 - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - return new(element); - } - case "percent": +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfigConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": { 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 "event_output": + case "tiered": { 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 } @@ -14554,51 +19732,38 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMatrixWithThresholdDiscountsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration : 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 + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > Cadence { get @@ -14607,7 +19772,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >("cadence"); } @@ -14653,6 +19818,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. /// @@ -14712,12 +19892,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14808,6 +19988,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -14846,19 +20039,19 @@ 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") + 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(); @@ -14870,32 +20063,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( FrozenDictionary rawData ) { @@ -14903,8 +20100,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14912,187 +20109,150 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( rawData ); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// [JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - : JsonModel +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence { - /// - /// 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); - } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this._rawData = new(rawData); + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence)( + -1 + ), + }; } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - 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 ); + } } /// -/// Configuration for a single property filter +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// Event property key to filter on + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string PropertyKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData ) { @@ -15101,7 +20261,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -15109,83 +20269,95 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( rawData ); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel { /// - /// Amount per unit + /// Inclusive tier starting value /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The lower bound for this tier + /// Amount per unit /// - public string? TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.UnitAmount; _ = this.TierLowerBound; + _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -15194,7 +20366,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15202,114 +20374,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - string unitAmount - ) - : this() - { - this.UnitAmount = unitAmount; - } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.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) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15327,7 +20416,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15336,7 +20425,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15345,7 +20434,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -15356,7 +20445,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. /// /// /// @@ -15377,7 +20466,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. /// /// /// @@ -15397,7 +20486,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. /// /// @@ -15408,8 +20497,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15429,7 +20518,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -15438,7 +20527,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. /// /// @@ -15449,8 +20538,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15465,16 +20554,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15493,18 +20582,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? 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() { @@ -15512,13 +20601,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15547,12 +20649,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15569,12 +20669,10 @@ JsonSerializerOptions 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,7 +20681,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -15592,7 +20690,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15602,11 +20700,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -15614,7 +20712,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -15623,13 +20721,28 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); + } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -15669,21 +20782,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 +20841,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15839,6 +20937,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -15878,18 +20989,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15901,32 +21012,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( FrozenDictionary rawData ) { @@ -15934,8 +21049,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15943,14 +21058,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -15959,9 +21074,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -15971,10 +21086,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProra Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15983,26 +21098,27 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence)( - -1 - ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -16010,182 +21126,114 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig - : JsonModel -{ - /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( - rawData + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options ); + } } /// -/// Configuration for a single tiered with proration tier +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Inclusive tier starting value + /// The event property used to group before applying thresholds /// - public required string TierLowerBound + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// Amount per unit + /// The maximum amount to charge each group /// - public required string UnitAmount + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("unit_amount", value); } + 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.TierLowerBound; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -16194,7 +21242,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16202,8 +21250,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16211,22 +21259,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16244,7 +21292,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16253,7 +21301,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16262,7 +21310,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -16273,7 +21321,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 +21342,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 +21362,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 +21373,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16346,7 +21394,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -16355,7 +21403,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 +21414,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16382,16 +21430,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16410,18 +21458,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? 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() { @@ -16429,13 +21477,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16464,12 +21525,10 @@ JsonSerializerOptions 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 +21545,10 @@ JsonSerializerOptions 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 +21557,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16509,7 +21566,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16519,11 +21576,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// @@ -16531,7 +21588,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > Cadence { get @@ -16540,7 +21597,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >("cadence"); } @@ -16548,18 +21605,18 @@ public required ApiEnum< } /// - /// Configuration for grouped_with_min_max_thresholds pricing + /// Configuration for cumulative_grouped_allocation pricing /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" ); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -16660,12 +21717,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16756,6 +21813,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +21865,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -16818,32 +21888,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( FrozenDictionary rawData ) { @@ -16851,8 +21925,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16860,14 +21934,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( rawData ); } @@ -16876,9 +21950,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -16888,10 +21962,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinM Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16900,19 +21974,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, _ => - (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence)( + (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( -1 ), }; @@ -16920,7 +21994,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16928,17 +22002,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -16950,89 +22024,92 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// The overall allocation across all groups /// - public required string GroupingKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// The maximum amount to charge each group + /// The allocation per individual group /// - public required string MaximumCharge + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("group_allocation"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("group_allocation", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// The event property used to group usage before applying allocations /// - public required string MinimumCharge + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The base price charged per group + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -17041,7 +22118,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -17049,8 +22126,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17058,22 +22135,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17091,7 +22168,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17100,7 +22177,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17109,7 +22186,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -17120,7 +22197,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 +22218,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 +22238,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 +22249,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17193,7 +22270,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -17202,7 +22279,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 +22290,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17229,16 +22306,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17257,18 +22334,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? 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() { @@ -17276,13 +22353,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17311,12 +22401,10 @@ JsonSerializerOptions 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 +22421,10 @@ JsonSerializerOptions 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 +22433,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17356,7 +22442,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17366,11 +22452,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance : JsonModel { /// @@ -17378,7 +22464,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > Cadence { get @@ -17387,7 +22473,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >("cadence"); } @@ -17395,18 +22481,18 @@ public required ApiEnum< } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for daily_credit_allowance pricing /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -17507,12 +22593,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17603,6 +22689,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22741,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -17665,32 +22764,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance( FrozenDictionary rawData ) { @@ -17698,8 +22801,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17707,14 +22810,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance.FromRawUnchecked( rawData ); } @@ -17723,9 +22826,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -17735,10 +22838,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroup Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17747,27 +22850,26 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, - _ => - (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( - -1 - ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -17775,17 +22877,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -17797,58 +22899,195 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + : JsonModel +{ + /// + /// Credits granted per day. Lose-it-or-use-it; does not roll over. + /// + public required string DailyAllowance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("daily_allowance"); + } + init { this._rawData.Set("daily_allowance", value); } + } + + /// + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value + /// + public required string DefaultUnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("default_unit_amount"); + } + init { this._rawData.Set("default_unit_amount", value); } + } + + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); + } + init + { + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Event property whose value identifies the day bucket the event belongs to + /// (e.g. 'event_day' set to an ISO date string in the customer's timezone). + /// The allowance resets per distinct value of this property. + /// + public required string EventDayProperty + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_day_property"); + } + init { this._rawData.Set("event_day_property", value); } + } + + /// + /// Per-dimension credit rates + /// + public required IReadOnlyList MatrixValues + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("matrix_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("matrix_values", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue : 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 + /// One or two matrix keys to filter usage to this value by. For example, ["model"] + /// could be used to apply a different credit rate to each AI model. /// - public required string GroupAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullStruct>("dimension_values"); } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("grouping_key", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -17863,23 +23102,24 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( IReadOnlyDictionary rawData ) { @@ -17888,7 +23128,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -17896,8 +23136,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17905,22 +23145,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17938,7 +23178,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17947,7 +23187,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17956,7 +23196,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( JsonElement element ) { @@ -17967,7 +23207,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 +23228,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 +23248,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 +23259,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18040,7 +23280,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -18049,7 +23289,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 +23300,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18076,16 +23316,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18104,18 +23344,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18123,13 +23363,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18158,12 +23411,10 @@ JsonSerializerOptions 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 +23431,10 @@ JsonSerializerOptions 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 +23443,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( element ); } @@ -18203,7 +23452,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -18213,25 +23462,29 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -18251,18 +23504,18 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// Configuration for metered_allowance pricing /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig MinimumConfig + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullClass( + "metered_allowance_config" ); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("metered_allowance_config", value); } } /// @@ -18350,12 +23603,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -18446,6 +23699,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -18486,8 +23752,13 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -18503,32 +23774,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance subscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance( FrozenDictionary rawData ) { @@ -18536,8 +23811,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18545,22 +23820,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -18570,10 +23848,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18581,23 +23859,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -18605,17 +23885,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -18627,39 +23907,104 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// The grouping_key value whose summed quantity represents the allowance for + /// this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + /// consumption — credit can never exceed actual usage. /// - public required string MinimumAmount + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("allowance_grouping_value"); + } + init { this._rawData.Set("allowance_grouping_value", value); } + } + + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); + } + init { this._rawData.Set("consumption_grouping_value", value); } + } + + /// + /// Event property used to partition the metric into consumption and allowance + /// quantities (e.g. 'event_name'). The metric is queried with this key and the + /// two values below select which partition is which. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + /// + public string? AllowanceDisplayName + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public bool? Prorated + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("consumption_display_name"); } init { @@ -18668,25 +24013,35 @@ public bool? Prorated return; } - this._rawData.Set("prorated", value); + this._rawData.Set("consumption_display_name", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig() { } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig() + { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig subscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig subscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig) { } + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -18695,7 +24050,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( FrozenDictionary rawData ) { @@ -18703,40 +24058,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -18754,7 +24100,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18763,7 +24109,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18772,7 +24118,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -18783,7 +24129,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 +24150,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 +24170,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 +24181,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18856,7 +24202,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -18865,7 +24211,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 +24222,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18892,16 +24238,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18920,18 +24266,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18939,13 +24285,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 SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18974,12 +24333,10 @@ JsonSerializerOptions 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 +24353,10 @@ JsonSerializerOptions 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 +24365,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( element ); } @@ -19019,7 +24374,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -19262,6 +24617,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +24687,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19328,10 +24697,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 +24847,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 +24950,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 +24971,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 +24991,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 +25002,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19657,7 +25032,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 +25043,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19720,10 +25095,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 +25106,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +25154,10 @@ JsonSerializerOptions 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 +25174,10 @@ JsonSerializerOptions 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 +25442,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +25517,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -20129,10 +25527,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 +25710,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 +25816,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 +25837,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 +25857,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 +25868,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20494,7 +25898,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 +25909,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20557,10 +25961,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 +25972,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +26020,10 @@ JsonSerializerOptions 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 +26040,10 @@ JsonSerializerOptions 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..af7ca0060 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs @@ -14,13 +14,25 @@ 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: uncancellation is a lossy operation. Price intervals that were cut +/// short by the cancellation are extended to infinity (original end dates are lost), +/// and future intervals or phases scheduled after the cancellation time are permanently +/// deleted. For complex subscriptions with phases or scheduled plan changes, consider +/// creating a new plan change instead of uncancelling. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking 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 +40,7 @@ SubscriptionUnscheduleCancellationParams subscriptionUnscheduleCancellationParam { this.SubscriptionID = subscriptionUnscheduleCancellationParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionUnscheduleCancellationParams( IReadOnlyDictionary rawHeaderData, @@ -42,24 +55,56 @@ 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) @@ -81,4 +126,9 @@ internal override 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..a13105edc 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,91 @@ 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`. A `decrement` entry records credits as + /// usage and immediately recognizes revenue at the block's `per_unit_cost_basis`. + /// + /// For most credit removals, use `void` (no revenue impact) or + /// `expiration_change` (revenue recognized on expiration) instead. Only use + /// `decrement` when credits were genuinely consumed outside of normal event + /// ingestion. + /// + /// 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 +210,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 +229,91 @@ 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`. A `decrement` entry records credits as + /// usage and immediately recognizes revenue at the block's `per_unit_cost_basis`. + /// + /// For most credit removals, use `void` (no revenue impact) or + /// `expiration_change` (revenue recognized on expiration) instead. Only use + /// `decrement` when credits were genuinely consumed outside of normal event + /// ingestion. + /// + /// 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 +324,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 +347,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 +440,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 +456,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 +472,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 +488,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..5d1969a37 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,37 @@ 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), 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. + /// + /// For credit blocks created by subscription allocation prices, this endpoint + /// returns the subscription invoice containing the allocation line item that + /// created the block. + /// + /// If the credit block was not purchased (e.g., manual increment), 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 +112,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 +128,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 +142,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..f4f7e37dd 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,18 +64,24 @@ 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 /// regularly refreshes invoices asynchronously. + /// + /// If you don't need line item details, minimums, maximums, or discounts, + /// prefer the [list invoices summary](/api-reference/invoice/list-invoices-summary) + /// endpoint for better performance. /// Task List( InvoiceListParams? parameters = null, @@ -78,8 +91,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 +108,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 +124,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 +135,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 +154,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 +217,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 +236,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 +268,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 +277,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 +293,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 +302,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 +318,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 +334,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 +343,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 +359,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 +384,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 +400,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 +411,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..e87f4dc0c 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,8 @@ 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 list [metrics](/core-concepts#metric). It returns + /// information about the metrics including its name, description, and item. /// Task List( MetricListParams? parameters = null, @@ -64,8 +67,9 @@ Task List( ); /// - /// This endpoint is used to list [metrics](/core-concepts#metric). 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 Fetch( MetricFetchParams parameters, @@ -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..c7c32b311 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`, `description`, 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..82acb05f6 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,18 @@ 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. + /// + /// Note: uncancellation is a lossy operation. Price intervals that were cut + /// short by the cancellation are extended to infinity (original end dates are + /// lost), and future intervals or phases scheduled after the cancellation time are + /// permanently deleted. For complex subscriptions with phases or scheduled plan + /// changes, consider creating a new plan change instead of uncancelling. /// Task UnscheduleCancellation( SubscriptionUnscheduleCancellationParams parameters, @@ -843,8 +879,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 +919,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 +942,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 +988,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 +997,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 +1013,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 +1022,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 +1038,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 +1054,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 +1070,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 +1086,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 +1102,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 +1118,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 +1134,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 +1150,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 +1166,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 +1182,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 +1198,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 +1214,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 +1230,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..1a48c987b 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`, `description`, 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